bugfix: fix eager state miss https://github.com/facebook/react/issues… #34065
+170
−164
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…/34061
Summary
I open a issue to explain this: #34061
==== the issue content ======
console:
Strange, why is child0 1 printed one more time here?
Isn't there eager state? If the state hasn't changed, it shouldn't re-render, right?
I didn't use StrictMode
I debug react:
I'm not using concurrent rendering either—so why does the 0 === fiber.lanes check fail?
Isn't fiber.lanes supposed to be cleared after the update is finished?
======
How did you test this change?
very small change, I use
yarn test
to run tests on my code.Then I build it with the following command:
After building, I link the react and react-dom packages to a project created with create-react-app. I initially tried linking them to a Vite project, but Vite threw some errors that vite can't use commonJS package.
However, the create-react-app project also throws an error:
I didn’t modify useState, so this is really strange. Maybe I built it incorrectly?
but I run
yarn test
, only a few test didn't pass(17), like original project that i didn't modify anything.