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

fix: perform sync update when exiting animation #885

Open asapach opened 1 year ago

asapach commented 1 year ago

When running in React 18 concurrent mode some state updates are batched, which results in inconsistent timing of events compared to the legacy mode. For example when using animations, after animationend event fires, the onExited event is not fired immediately, so there is a brief period of time when animation is finished and the styles are reset back to normal, which may cause a flash or a jump. One of these scenarios is described in #816.

This change makes sure that the updates are performed synchronously, in order to make sure that events fire consistently.