Eager bailout optimization should always compare to latest reducer#15124
Merged
acdlite merged 3 commits intofacebook:masterfrom Mar 16, 2019
Merged
Eager bailout optimization should always compare to latest reducer#15124acdlite merged 3 commits intofacebook:masterfrom
acdlite merged 3 commits intofacebook:masterfrom
Conversation
This name is a bit more descriptive.
Collaborator
|
I tried fixing it like this, and it also passed tests: 6670512. Is my fix wrong? If yes, can we add a new case that this naïve fix would fail? |
Collaborator
Author
|
@gaearon That's essentially the same fix except in yours doesn't account for the render phase updates path. So I think it would break if an earlier state in the same component gets a render phase update, and then a subsequent inline reducer closes over that. I'll see if I can write a test case where that would fail. |
Collaborator
Author
|
Added additional test that fails if reducer is not updated in the render phase updates branch. |
gaearon
approved these changes
Mar 16, 2019
gaearon
pushed a commit
to gaearon/react
that referenced
this pull request
Mar 27, 2019
…acebook#15124) * Eager bailout optimization should always compare to latest reducer * queue.eagerReducer -> queue.lastRenderedReducer This name is a bit more descriptive. * Add test case that uses preceding render phase update
Closed
This was referenced Aug 12, 2019
This was referenced Feb 4, 2020
This was referenced Feb 17, 2020
This was referenced Feb 25, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Based on a bug report by @pomber
https://mobile.twitter.com/pomber/status/1106667842844401670
The issue was that the queue contains a reference to the last rendered reducer, but we weren't updating it in all cases, so sometimes it was stale, triggering the bailout incorrectly.
The original bug report (https://codesandbox.io/s/yj605043yv) had an additional bug in it that made it a bit more confusing, which is it did not specify an initial state. I did not include that part in my test case because it wasn't relevant to the actual underlying bug.