-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
useEffect didn't run in some rare case (lazy + memo) #4631
Comments
This shortcoming originates from the detaching logic, located here currently it bubbles up in a straight line but it should reset every child up until the Suspense boundary, including siblings. Edit: wait it does, but somehow the memo'd component just bails... we might need to set _force to true - I guess a similar fix would be needed for #3449 either way |
I noticed the bug disappears if replace the |
As outlined in my comment it's a bug with memoization and can be addressed in the detaching logic by i.e. setting |
I may have some misunderstanding about the issue. The We can resolve it either:
And we choose to use plan 1. Do I get your thought correctly? |
That's not right, everything works correctly it's just that the effect isn't reexecuted which your PR's test is not testing. As you can see in the reproduction a few things happen, one of which is that the sibling lazy boundary suspends. This means that What we want instead is for this component to be successfully remounted which we can trigger by means of Your test is almost right in your branch with the exception that you are not testing that the |
Got what you mean. But here, if they don't wrapped by |
I think I get the answer. Cuz without div, the |
Describe the bug
I have a simple app with the following structure:
I found that in this case, Foo's useEffect() will NOT be executed. (But it does in React 18)
To Reproduce
https://codesandbox.io/p/sandbox/preact-memo-gpmrxk
Expected behavior
Show foobar
Actual behavior
Show bar
The text was updated successfully, but these errors were encountered: