Skip to content

[bug]: useTransition destroys element too early #2382

Open
@michalvadak

Description

@michalvadak

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?

The useTransition sometimes destroys the element before calling transitionApi.start() resulting in the animation not playing as the element has been destroyed. Video evidence is attached below.

Zaznam.obrazovky.2025-06-04.v.12.11.02.mov

Also, the use of the useTransition function is problematic when using a spring ref and switching the state from empty array to array of data. The elements are then mounted in the DOM without waiting for the transitionApi.start() (just the animation is waiting).

To Reproduce

  1. Setup useTransition with the spring ref
  2. Change the state that's in useTransition
  3. Call the transitionApi.start()
  4. Repeat until it breaks

Expected Behaviour

The useTransition should wait for the transitionApi.start() call to mount/unmount the component.

Link to repo

https://stackblitz.com/edit/vitejs-vite-yuqpbeeh

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