From 6eebfa11efca06386d394273918e417d1178a8db Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Wed, 18 Mar 2026 23:45:15 +0100 Subject: [PATCH] Use state instead of ref for main element portal target Replace mainRef with useState to avoid accessing ref.current during render, which is forbidden by React 19's strict ref rules. Signed-off-by: Bryan Frimin --- .../pages/organizations/audits/AuditsPage.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/console/src/pages/organizations/audits/AuditsPage.tsx b/apps/console/src/pages/organizations/audits/AuditsPage.tsx index 2200bbe85..1e3ba18ed 100644 --- a/apps/console/src/pages/organizations/audits/AuditsPage.tsx +++ b/apps/console/src/pages/organizations/audits/AuditsPage.tsx @@ -190,22 +190,23 @@ export default function AuditsPage(props: Props) { setDroppedFile(null); }; - const mainRef = useRef(null); + const [mainEl, setMainEl] = useState(null); useEffect(() => { - mainRef.current = document.querySelector("main"); - if (mainRef.current) { - mainRef.current.style.position = "relative"; + const el = document.querySelector("main"); + if (el) { + el.style.position = "relative"; + setMainEl(el); } return () => { - if (mainRef.current) { - mainRef.current.style.position = ""; + if (el) { + el.style.position = ""; } }; }, []); return (
- {isDragging && canCreateAudit && mainRef.current && createPortal( + {isDragging && canCreateAudit && mainEl && createPortal(
, - mainRef.current, + mainEl, )}