-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
New class instantiation and initialization process #2808
Conversation
914da32
to
548ea09
Compare
@@ -123,7 +109,7 @@ var ReactCompositeComponentMixin = assign({}, | |||
this._rootNodeID = null; | |||
|
|||
this._instance.props = element.props; | |||
this._instance.state = null; | |||
// state gets set up during mount |
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.
Is state
is already set to null
here from the constructor?
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.
Er… never mind; the constructor calls getInitialState. This comment seems wrong then.
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.
well it gets reset during mount. this can be simplified later. if it's undefined, it gets set to null.
lgtm |
This allows state to be set up in the constructor instead of through getInitialState. getInitialState is now considered part of "classic". Therefore, they move into ReactClass's constructor. As a consequence of this, we no longer have a mapping between the internal representation and the public instance during the mounting process. Because the constructor hasn't returned yet. We used to have a special case for calling setState in getInitialState which was just ignored. This makes that throw and the component is considered unmounted during the construction phase.
548ea09
to
291a92c
Compare
New class instantiation and initialization process
Builds on top of #2806
This allows state to be set up in the constructor instead of through
getInitialState. getInitialState is now considered part of "classic".
Therefore, they move into ReactClass's constructor.
As a consequence of this, we no longer have a mapping between the internal
representation and the public instance during the mounting process.
Because the constructor hasn't returned yet.
We used to have a special case for calling setState in getInitialState
which was just ignored. This makes that throw and the component is
considered unmounted during the construction phase.