Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Changing state does hot reload #41

Closed
gkiely opened this issue Dec 25, 2015 · 3 comments
Closed

Changing state does hot reload #41

gkiely opened this issue Dec 25, 2015 · 3 comments

Comments

@gkiely
Copy link

gkiely commented Dec 25, 2015

Node: 5.3.0
presets: ["react", "es2015", "stage-0"],

class App extends Component {
  state = {msg: "myMsg"}

  render() {
    return (
      <div>
        <h1>{this.state.msg}</h1>
      </div>
    );
  }
}

Changing myMsg does not hotreload, mapping it to a variable outside the class does.

@gaearon
Copy link
Owner

gaearon commented Dec 25, 2015

It can't hot reload changes to the initial state. Don't forget this property assignment is equivalent to setting the field inside the constructor. Even if you change the constructor, the field has already been set. Constructor doesn't run twice. So this is not supported.

@gaearon gaearon closed this as completed Dec 25, 2015
@gkiely
Copy link
Author

gkiely commented Dec 27, 2015

Ahhh I thought this might be the case, out of curiosity would it be possible to unmount and remount the component to get this to work? I don't know enough about react yet to know whether or not this is possible.

@gaearon
Copy link
Owner

gaearon commented Dec 27, 2015

Maybe. You can track gaearon/react-proxy#15 for that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants