News for hackers. Stuff that matters.
Re:Simple React Patterns by whistlerbrk on Friday November 10, 2017 @11:05AM (#15670774)
Not clear on what you're saying, pseudocode?
Re:Simple React Patterns by topgunsarg on Friday November 10, 2017 @11:10AM (#15670820)
In componentWillUnmount, set a var componentUnmounted true. In componentDidMount in the callback for the fetch, check for componentUnmounted before setting state for an error or whatever you want to do.
Re:Simple React Patterns by travmatt on Friday November 10, 2017 @12:40PM (#15671494)
Set a variable... set a property in the component state? Or set a static variable on the class?
Re:Simple React Patterns by pcmaffey on Friday November 10, 2017 @01:04PM (#15671684)
I use a static var on the class.

  componentDidMount() {
   if (!this.unmounted) ...
  }

  componentWillUnmount() {
   this.unmounted = true
  }
Re:Simple React Patterns by fatso83 on Saturday November 11, 2017 @05:43AM (#15675794)
That's not a static car on the class. It's on the instance! A static class property would entail something like `Foo.unmounted = true` (a bad idea).