coryhouse / react-flux-starter-kit

Quickly get started with React and Flux using Browserify and Gulp
682 stars 247 forks source link

setState is async #11

Closed chookie closed 5 years ago

chookie commented 7 years ago

Sorry to be back again but I think the call to toastr.success and transitionTo should be in a callback since setState is asynchronous. I could not work out why I kept getting the warning about leaving changes until I remembered from another course.

I think in the module React Forms/Transitions:3:35 I think the code should be something like:

  this.setState({dirty: false}, function() {
    toastr.success('Author saved.');
    this.transitionTo('authors');
  });

Again, great course thanks.

coryhouse commented 7 years ago

That's a great point. I've added this to the list of items I plan to patch.

coryhouse commented 5 years ago

The course has been updated as of 6/2019. This issue has been addressed in the update.