-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: In react 18, flashing effect appears at the end of exit phase before entering #816
Comments
Friends, I have what I believe is the same issue, but in my case I'm animating a slide transition from right-to-left using 3D translate affecting the X value. The "new" component enters from the right, while the "old" component simultaneously exits to the left. What I'm seeing a perfectly executed transition until the very end, and then you see a brief flash of the old exiting component superimposed over the newly-entered component. In theory, it should be impossible to see the old exited component at the end of the animation because the 3D translate rules, if processed as designed, would mean the exited component X value would place the old component 100% off screen. There should be no way to "see" the brief flash of the old exited component. I am confident that the cause of this problem is the React 18 update batching, because I've been able to ameliorate the problem by doing the safeSetState using flushSync. IMPORTANT: It is apparently only necessary to "wrap" the nextState value of exited with flushSync; all other nextState values (entering, entered, exiting) can be done using setState in the normal manner. I believe that state-transitions exiting and exited are being erroneously combined into a single batch update by React 18. This cannot be permitted, or the animation will be impacted. The updates for exiting and exited must not be batched. It is necessary to fully process the exiting state before setting exited state. I hope this makes sense, this stuff is very complicated and hard to get your head around. Here is my fix.
|
thanks!! so much, buddy. I have patched the package using your fix, and now it WORKs LIKE A CHARM!! |
It doesn't seem to me this was ever fixed/released even though this is marked as completed? |
not fixed yet with the recently released version 4.4.5 here is the commit to fix c20af7c |
are there any plans to fix this and release a new version? |
This bug is still relevant. |
1 similar comment
This bug is still relevant. |
@tranvansang is there a chance to release a new version with the fix? |
here it is react-transition-group-react-18 or you can patch locally (tutorial) |
@tranvansang I expected the existing package to be fixed rather than a new package being released. |
Im not the author of the package. Cannot publish any new version of it |
I'm guessing there was confusion caused by the commit attached above. What prevented you from creating PR? |
@tranvansang I've found an alternate fix to your original issue: you can set |
I've created a PR: #885 |
reactjs#885 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 reactjs#816. This change makes sure that the updates are performed synchronously, in order to make sure that events fire consistently.
What is the current behavior?
When clicking the button

What is the expected behavior?
Phase 3 shouldn't exist in react 18 renderer.
Could you provide a CodeSandbox demo reproducing the bug?
In demo's index.js, try changing
legacyReact
value to switch react 18 behav2022-04-12.08-15-18.mp4
ior.
https://codesandbox.io/s/wonderful-glade-n0n92s?file=%2Fsrc%2Findex.js
The text was updated successfully, but these errors were encountered: