-
Notifications
You must be signed in to change notification settings - Fork 47k
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
isMounted behavior different with create-react-class
#9627
Comments
I fixed this locally by splitting the IsMountedMixin into two: var IsMountedPreMixin = {
componentDidMount: function () {
this.__isMounted = true;
}
};
var IsMountedPostMixin = {
componentWillUnmount: function () {
this.__isMounted = false;
}
}; Then installing the Post after the spec has been mixed in: mixSpecIntoComponent(Constructor, IsMountedPreMixin);
mixSpecIntoComponent(Constructor, spec);
mixSpecIntoComponent(Constructor, IsMountedPostMixin); For the life of me I can't find the right repo to PR this against though. |
Split the IsMountedMixin in two so that the __isMounted flag is set to false after componentWillUnmount is executed in mixins and the component.
* [#9627] Fix create-react-class isMounted ordering issue Split the IsMountedMixin in two so that the __isMounted flag is set to false after componentWillUnmount is executed in mixins and the component. * Revert changes to integration test
…book#9638) * [facebook#9627] Fix create-react-class isMounted ordering issue Split the IsMountedMixin in two so that the __isMounted flag is set to false after componentWillUnmount is executed in mixins and the component. * Revert changes to integration test
This should be fixed with |
I don't see that version published yet. |
It's not set to https://unpkg.com/[email protected]/ Will turn into 15.6.0 tomorrow. |
Ah indeed. It's probably our internal registry being slow. I'll try it out soon. |
Confirmed working correctly in |
Great. Thanks for sending the fix! |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Calling
this.isMounted()
incomponentWillUnmount
in prior versions would returntrue
. Now it returnsfalse
.I believe this was untested behavior before, but the new tests that were added may check the wrong value: https://github.com/facebook/react/blob/master/src/isomorphic/classic/class/__tests__/create-react-class-integration-test.js#L417 Changing this line to test for
true
will exhibit the behavior.The fix would be to defer setting the
__isMounted
flag tofalse
until after all mixins and thecomponentWillUnmount
method were called on the component.Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
15.5.x and anything using
create-react-class
is broken. Working correctly in 15.4.x withReact.createClass
.The text was updated successfully, but these errors were encountered: