-
-
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
fix case where we set SCU multiple times #3670
Conversation
Size Change: -5 B (0%) Total Size: 43.9 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code change looks straightforward. I confirm this fixes the test failures encountered in our app when going from Preact 10.10.0 => 10.10.1: hypothesis/lms#4335.
@@ -234,6 +234,31 @@ describe('useState', () => { | |||
expect(scratch.textContent).to.equal('hi'); | |||
}); | |||
|
|||
it('correctly updates with multiple state updates', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to add a comment mentioning the original issue, since the sequence of updates needed to trigger the problem is quite specific, rather than this being just a general test for multiple states in one component.
Fixes #3669
We were setting
hookState._component.__hooks._hasScuFromHooks = true;
rather thanhookState._component._hasScuFromHooks
which becomes problematic as we start setting as many SCU's as there are stateful hooks in a component.On the bright side found a golfing opportunity