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-time this.setState(this.getInitialState()) call somewhere to initialise the state and avoid TypeError: this.state is null in render().
Is it possible to detect that a getInitialState() has just been added to a component (or that state is null and getInitialState() exists, or some other heuristic) and have react-proxy do the setState(this.getInitialState()) bit for me, and is react-proxy the right place to do this?
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?