Skip to content

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

@hjeti

Description

@hjeti

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions