Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useExposeAnimation does only expose the new animation after a rerender. #153

Open
hjeti opened this issue Jun 28, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@hjeti
Copy link

hjeti commented Jun 28, 2023

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 the useEffect of the useExposeAnimation 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 the useExposeAnimation logic into the useAnimation hook. The exposing should not be enabled by default so I have 2 extra optional parameters in my hook that are expose and the ref that will control the exposing from the useAnimation.

@hjeti hjeti added the bug Something isn't working label Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant