From 97be755d12cd2f447bdc0f7940cb77576bace4e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Zakraj=C5=A1ek?= Date: Tue, 25 Oct 2022 13:32:44 +0200 Subject: [PATCH] Document missing useLayoutEffect popper dependency DropdownMenu uses `useLayoutEffect` to update `popper`. If you want to make ESLint happy and add `popper` as a `useLayoutEffect` hook dependency this causes an endless loop because `popper` object changes on every render. It makes sense to have this in the documentation because it is painful to debug why the app freezes when you toggle the menu. --- www/docs/Dropdown.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/docs/Dropdown.mdx b/www/docs/Dropdown.mdx index a84acce..9dc53af 100644 --- a/www/docs/Dropdown.mdx +++ b/www/docs/Dropdown.mdx @@ -30,6 +30,9 @@ const DropdownMenu = ({ role }) => { useLayoutEffect(() => { if (show) popper.update(); + // useLayoutEffect must not depend on popper as this causes an endless loop + // because popper object changes on every render + // eslint-disable-next-line react-hooks/exhaustive-deps }, [show]); return (