Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Eager bailout optimization should always compare to latest reducer #15124
Based on a bug report by @pomber
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.
@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.