Skip to content

[BUG] AnimatePresence fails to detect motion component unmount on next render after exit animation #3243

@hyp3rflow

Description

@hyp3rflow

When a child component inside AnimatePresence is unmounted immediately after its exit animation is triggered, the exit state gets stuck.

CodeSandbox repro

Steps to reproduce

  1. Click the "Toggle" button. This triggers the exit animation via AnimatePresence, and on the next render, the motion component inside the child gets unmounted.

  2. The child component gets stuck in the exit state and incorrectly shows the "closed" text.

Expected behavior

There's already logic to skip the exit state when there are no exiting components, so ideally, the exit animation should be stopped immediately in such cases.

I wonder if this issue could be resolved by adding forceRender at this line, but I'm still new to the codebase, so I'd appreciate any insights or confirmation on whether that would be a valid approach.

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