Skip to content

Bug: ViewTransition onExit cleanup not called on unmount #35855

@rickhanlonii

Description

@rickhanlonii

Noticed this while writing docs:

<ViewTransition
  onEnter={(instance) => {
    const anim = instance.new.animate(/* ... */);
    return () => {
      anim.cancel();
    };
  }}
  onExit={(instance) => {
    const anim = instance.new.animate(/* ... */);
    return () => {
      anim.cancel();
    };
  }}
>
  {/* ... */}    
</ViewTransition>

If you have a pendingonEnter animation and the tree is unmounted, the onEnter cleanup is called immediately.

But if you have a pending onExit and the tree is unmounted, the onExit cleanup isn't called until the animation completes.

This means you can't cancel the animation:

Screen.Recording.2026-02-21.at.11.11.57.AM.mov

Sandbox: https://codesandbox.io/p/sandbox/naughty-wu-pfkh2m

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions