reactjs / react-transition-group

An easy way to perform animations when a React component enters or leaves the DOM
https://reactcommunity.org/react-transition-group/
Other
10.1k stars 652 forks source link

Unexpected behavior while working with useState #888

Open arkni8 opened 1 year ago

arkni8 commented 1 year ago

What is the current behavior?

Currently, I am seeing no updating of state. When I am trying to update a useState variable - the variable just fails to update. It could possibly be because using SwitchTransition component somehow changes the block scope. Not sure how, and I could be wrong but that's what I am thinking.

What is the expected behavior?

Expected behavior - Change the useState variable as I want it to. You will see, if you comment out the SwitchTransition component from App.js file - everything starts working as expected. The entry animations will play when you press Next. The useState variable updates properly. But as soon as you insert SwitchTransition back - the component stops updating.

Bonus problem/guidance needed - How can I make the exit animation work?

Could you provide a CodeSandbox demo reproducing the bug?

Why, yes. Absolutely. Codesandbox link here