Modal closes immediately in React18 strict mode.
yuta-ike opened this issue · 1 comments
yuta-ike commented
Under react18 strict mode (such as Next.js development environment), modal opens but immediately closed. This may be caused by the change in react18 that useEffect is now called twice.
modal_bug.mov
reproduction procedure
- Wrap app component in
examples/src/index.tsx
withReact.StrictMode
and runnpm start
. - Open
http://localhost:3000/react-hooks-use-modal/
and click OPEN button.
My reproduction branch
https://github.com/yuta-ike/react-hooks-use-modal/blob/ea043c086e31776c2626695c56a5156035af74a0/examples/src/index.tsx#L64-L68
dc7290 commented
Fixes were released in version 3.3.1