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
-
Click the "Toggle" button. This triggers the exit animation via AnimatePresence, and on the next render, the motion component inside the child gets unmounted.
-
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.
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
Click the "Toggle" button. This triggers the exit animation via AnimatePresence, and on the next render, the motion component inside the child gets unmounted.
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.