Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Set a variable... set a property in the component state? Or set a static variable on the class?



I use a static var on the class.

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

  componentWillUnmount() {
   this.unmounted = true
  }


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).




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: