-
Notifications
You must be signed in to change notification settings - Fork 50
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
Initialise state when getInitialState() is added after the initial render using HMR #38
Labels
Comments
I think this is related to #15 |
Yeah it's probably the right place. Feel free to try to PR this :-) |
robertknight
added a commit
to robertknight/react-proxy
that referenced
this issue
Jan 24, 2016
When replacing a proxied component that has no state with one that does have state, renders and lifecycle methods that depend on the initial state will typically fail with 'this.state is null' errors. This addresses the issue by invoking getInitialState() on classic components or running the constructor for modern components and merging the resulting state with the existing state, with the existing state taking priority. Fixes gaearon#38
robertknight
added a commit
to robertknight/react-proxy
that referenced
this issue
Jan 24, 2016
When replacing a proxied component that has no state with one that does have state, renders and lifecycle methods that depend on the initial state will typically fail with 'this.state is null' errors. This addresses the issue by invoking getInitialState() on classic components or running the constructor for modern components and merging the resulting state with the existing state, with the existing state taking priority. Fixes gaearon#38
robertknight
added a commit
to robertknight/react-proxy
that referenced
this issue
Mar 6, 2016
When replacing a proxied component that has no state with one that does have state, renders and lifecycle methods that depend on the initial state will typically fail with 'this.state is null' errors. This addresses the issue by invoking getInitialState() on classic components or running the constructor for modern components and merging the resulting state with the existing state, with the existing state taking priority. Fixes gaearon#38
robertknight
added a commit
to robertknight/react-proxy
that referenced
this issue
Mar 6, 2016
When replacing a proxied component that has no state with one that does have state, renders and lifecycle methods that depend on the initial state will typically fail with 'this.state is null' errors. This addresses the issue by invoking getInitialState() on classic components or running the constructor for modern components and merging the resulting state with the existing state, with the existing state taking priority. Fixes gaearon#38
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I'm working with hot reloading and adding state to a
React.createClass
component which didn't have it before, I usually have to hack in a one-timethis.setState(this.getInitialState())
call somewhere to initialise the state and avoidTypeError: this.state is null
inrender()
.Is it possible to detect that a
getInitialState()
has just been added to a component (or that state isnull
andgetInitialState()
exists, or some other heuristic) and have react-proxy do thesetState(this.getInitialState())
bit for me, and is react-proxy the right place to do this?The text was updated successfully, but these errors were encountered: