Stanko / react-animate-height

Lightweight React component for animating height using CSS transitions. Slide up/down the element, and animate it to any specific height.
https://muffinman.io/react-animate-height
MIT License
756 stars 53 forks source link

React 18 (in StrictMode): Uncaught TypeError: Cannot read properties of null (reading 'animating') #123

Closed josephmarkus closed 2 years ago

josephmarkus commented 2 years ago

react-animate-height blows up in React 18. The library is used for an accordion component that animates on state toggle.

Code example https://codesandbox.io/s/lingering-wood-tjnu2k?file=/src/App.js

Expected behavior

Clicking 'Open' should expand the component that is wrapped with <AnimateHeight />. Instead, it blows up

Possible Solution

🤷‍♂️ 😅

Steps to Reproduce (for bugs)

  1. Go to https://codesandbox.io/s/lingering-wood-tjnu2k?file=/src/App.js
  2. Click 'Open'
  3. Observe the error

Screenshots

6eb58856-55b0-4e4c-9192-52381e025f3b

Your Environment

Additional context

n/a

Stanko commented 2 years ago

Hello, thanks for letting me know. It seems it blows up when StrictMode is enabled. I'll look into it. Cheers!

Stanko commented 2 years ago

Fixed in 2.1.0 🎉

Example: https://codesandbox.io/s/ecstatic-leaf-x652u4

josephmarkus commented 2 years ago

Amazing! Thank you!