Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Bug: ViewTransition onExit cleanup not called on unmount | GoodFirstPicks

Bug: ViewTransition onExit cleanup not called on unmount

facebook/react 2 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeReactJavaScriptTypeScript

Why this is a good first issue

The issue involves cleanup behavior during unmount with ViewTransition API which requires careful timing handling.

AI Summary

The problem is that `onExit` cleanup functions are not called immediately on unmount when using ViewTransition, unlike `onEnter` cleanup. This requires modifying the unmount behavior to ensure cleanup consistency. The main challenge is handling the timing correctly with the View Transitions API.

Issue Description

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:

https://github.com/user-attachments/assets/f522f746-5ed3-432f-acbf-d610ab4260d2

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

GitHub Labels

Status: Unconfirmed

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • Browser Specific API
  • timing-sensitive behavior
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno