-
Notifications
You must be signed in to change notification settings - Fork 623
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
chore: avoid throw error when update unmounted component #2223
Conversation
jest.useRealTimers(); | ||
}); | ||
|
||
it('should no error with class component', () => { |
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.
should warn with class component ?或者 should not throw error with class component
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.
done
if (process.env.NODE_ENV !== 'production') { | ||
// Block other render | ||
Host.__isUpdating = false; | ||
console.error( |
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.
是哪个组件调用的, warning 中能透出不
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.
日志可能会很多
@@ -117,6 +129,10 @@ function requestUpdate(component, partialState, callback) { | |||
|
|||
// setState | |||
if (partialState) { | |||
// Function Component should force update | |||
if (component.__isReactiveComponent) { | |||
internal.__isPendingForceUpdate = true; |
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.
这段位置调整的原因是?
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.
将之前 ReactiveComponent _update
方法中会导致报错的 this[INTERNAL]. __isPendingForceUpdate
移到这个地方
afb049a
to
d86da1e
Compare
React remove warning pr: facebook/react#22114 |
#2198
Before this change
this[INTERNAL].__isPendingForceUpdate = true
About this change