useExposeAnimation
does only expose the new animation after a rerender.
#153
Labels
bug
Something isn't working
If the dependencies change of an animation then in the
useEffect
it will create a new animation. The problem is that this animation is not directly exposed because at the time of the render the animation is still the old animation so theuseEffect
of theuseExposeAnimation
will not update. It will only update if the component is rendered again and that doesn't always happen. In a project this caused a retrigger of the in animations when a component was hovered. At the moment of the hover it would then all of a sudden expose the latest animation that was could already have been created a minute ago but was never exposed yet.In another project I have a wrapping hook around
useAnimation
that handles preloading and only triggering the animation when the preloader is gone. In that hook I now also do the exposing of the animation so the parent will always get the animation once it's created and not once the child is rerendered. I think that is also the solution to this problem, to merge theuseExposeAnimation
logic into theuseAnimation
hook. The exposing should not be enabled by default so I have 2 extra optional parameters in my hook that areexpose
and theref
that will control the exposing from theuseAnimation
.The text was updated successfully, but these errors were encountered: