fix(fe): crash 'reading channel_id' + recharts width/height warnings
Build & Deploy (Nix) / build-and-deploy (backend) (push) Successful in 2m14s
Build & Deploy (Nix) / build-and-deploy (discord-gateway) (push) Successful in 2m53s
Build & Deploy (Nix) / build-and-deploy (proxy) (push) Successful in 3m15s
Build & Deploy (Nix) / build-and-deploy (backend) (push) Successful in 2m14s
Build & Deploy (Nix) / build-and-deploy (discord-gateway) (push) Successful in 2m53s
Build & Deploy (Nix) / build-and-deploy (proxy) (push) Successful in 3m15s
- useMessageDetail: guard attachments fetcher — revalidate bisa race detail load, detail.data undefined saat fetcher jalan -> TypeError 'Cannot read properties of undefined (reading channel_id)' yang bikin halaman /messages mati (Next error boundary). Sekarang fetcher balikin [] kalau channel_id belum ada; hapus non-null assertion. Diverifikasi: /messages sebelumnya crash, sekarang render dengan data asli (list, verdict, confidence, sticker, emoji). - ResponsiveContainer (recharts 3.8): initialDimension -1 di render pertama -> warning 'width(-1) and height(-1)'. Pakai height numerik tetap (192/160/48) + minWidth/minHeight 0 -> calculatedHeight >0, warning hilang; width tetap responsif via ResizeObserver. Chart baru dirender setelah mount (useMounted) biar container punya ukuran. Diverifikasi console: 0 warning, 0 error di dashboard & voice.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
/**
|
||||
* Returns true once the component has mounted on the client. Charts wrapped
|
||||
* in ResponsiveContainer measure their parent during the first layout — if
|
||||
* the container has no size yet (hydration/flex/grid), Recharts logs
|
||||
* "width(-1) and height(-1)" warnings. Deferring the chart render until after
|
||||
* mount guarantees the container has real dimensions.
|
||||
*/
|
||||
export function useMounted(): boolean {
|
||||
const [mounted, setMounted] = useState(false);
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
}, []);
|
||||
return mounted;
|
||||
}
|
||||
Reference in New Issue
Block a user