Skip to content

[bug]: Calling .start() on a spring doesn't work if a re-render happens when using react-spring 10.0.1 #2385

@diegomacario

Description

@diegomacario

Which react-spring target are you using?

  • @react-spring/web
  • @react-spring/three
  • @react-spring/native
  • @react-spring/konva
  • @react-spring/zdog

What version of react-spring are you using?

10.0.1

What's Wrong?

I'm using the imperative API to start a spring when a component is first mounted in my website. My component also re-renders at that time because a variable in a zustand store changes:

  // This line is just here to cause a re-render of the component
  const { causeReRender } = useReRenderStore();

  useEffect(() => {
    heightSpringAPI.start({ progress: 1.0 });
  }, []);

The spring has always started properly until I switched from version 9.7.5 to version 10.0.1 of react-spring. Now it doesn't start at all.

To Reproduce

I have created a small repo that you can use to reproduce the bug: https://github.com/diegomacario/react-spring-bug

The repo simply animates a cube upwards when you open the website.

Image
  • The main branch uses react-spring 9.7.5 and React 18. The spring starts properly with those versions.
  • There is a branch called react-spring-10.0.1-with-react-18. The spring doesn't start with those versions.
  • There is a branch called react-spring-10.0.1-with-react-19. The spring doesn't start with those versions.

Here are some deploys that allow you to compare:

Expected Behaviour

Springs should start regardless of whether re-renders happen or not, like they always did.

Link to repo

https://github.com/diegomacario/react-spring-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions