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
758 stars 53 forks source link

Version 2.1.1 - matchMedia is not defined #125

Closed ritabazak closed 2 years ago

ritabazak commented 2 years ago

After upgrading to 2.1.1, we are getting an error that matchMedia is not defined in AnimateHeight.js. We are using react 16.14.0.

Stanko commented 2 years ago

Hello, Which browser or environment?

Btw AnimateHeight doesn't support super old browsers that do not support it: https://caniuse.com/?search=matchMedia

johnhunter commented 2 years ago

Also seeing this in jest tests

jest@27.5.1
jsdom@16.7.0

We have a check for window.matchMedia elsewhere in our code and this does not fail

  if (!('matchMedia' in window)) {
    throw new Error('`window.matchMedia` is not supported by this browser');
  }
Stanko commented 2 years ago

I just pushed 2.1.2 with the explicit check if matchMedia exists. Can you please confirm it works because I can't reproduce this locally. Thanks!

johnhunter commented 2 years ago

Will do, thanks.

johnhunter commented 2 years ago

That looks to have fixed my issues with Jest tests. Thanks for the quick turnaround! 🎉

ritabazak commented 2 years ago

Yes, we saw the issue in the tests, we are using:

enzyme@3.11.0
jsdom@11.12.0
jest@24.9.0

Will try now the fix as well, thank you :)