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 Animate Height Failed to compile with version 3 #129

Closed TrizBea24 closed 2 years ago

TrizBea24 commented 2 years ago

With the node version v16.14.0, the React version "16.13.1" and the react-animate-height" version "^3.0.3", I get the next issue: Failed to compile.

./node_modules/react-animate-height/dist/esm/index.js 17:32 Module parse failed: Unexpected token (17:32) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | // Check for element?.style is added cause this would fail in tests (react-test-renderer) | // Read more here: https://github.com/Stanko/react-animate-height/issues/17

if (height === 0 && element?.style) { | element.style.display = 'none'; | }

It is solved changing the version of react-animate-height to "^2.0.1".

Stanko commented 2 years ago

Hello there, I think I know what is going on, and I've released version 3.0.4, so please try that.

And please try to provide even more data when opening an issue (which tools are you using, is it a client, or server build...), it makes it much easier to pinpoint bugs like this. Thank you!

Cheers!

EDIT: The problem was that target in my tsconfig was set to esnext, I swapped it for es6: https://github.com/Stanko/react-animate-height/commit/edac80d04ee9fa499bd25de334c7ed8603b73ae5

TrizBea24 commented 2 years ago

Oh great! I just tried version 3.0.4 and It worked perfectly. Many thanks!