Closed Bdragon93 closed 1 year ago
Hey @Bdragon93,
Again, it is not problem with the library.
You've ordered your hooks wrong. On the first render setHeight("auto")
was called after setFixedHeight()
resulting in height always being being auto
. That means animation didn't trigger as height didn't change.
You need to reorder your hooks like this:
useEffect(() => {
console.log("set height to auto");
setHeight("auto");
}, [items]);
useEffect(() => {
console.log("mount");
setFixedHeight();
}, []);
Here is corrected sandbox: https://codesandbox.io/s/react-animate-height-animate-height-when-content-changes-forked-gunii1?file=%2Fsrc%2Findex.js
Please check the readme and your code more thoroughly before opening issues. You opened two and commented on the third issue and none of those were actual issues.
Hope this helps!
Cheers!
Code example https://codesandbox.io/s/react-animate-height-animate-height-when-content-changes-forked-5ntso0?file=/src/index.js
onHeightAnimationEnd
couldn't be triggered.Expected behavior
Possible Solution
AutoTest
defined in line 46, used in lines 93 and 99 byAutoHeight
defined in line 5.Steps to Reproduce (for bugs)
Your Environment
Additional context
onHeightAnimationEnd
is triggered before onLoad.