microcmsio/react-hooks-use-modal

Modal closes immediately in React18 strict mode.

yuta-ike opened this issue · 1 comments

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

  1. Wrap app component in examples/src/index.tsx with React.StrictMode and run npm start.
  2. 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

Fixes were released in version 3.3.1 🎉