Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
kshahkshah
on Nov 10, 2017
|
parent
|
context
|
favorite
| on:
Simple React Patterns
Not clear on what you're saying, pseudocode?
topgunsarg
on Nov 10, 2017
[–]
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.
travmatt
on Nov 10, 2017
|
parent
[–]
Set a variable... set a property in the component state? Or set a static variable on the class?
pcmaffey
on Nov 10, 2017
|
root
|
parent
[–]
I use a static var on the class.
componentDidMount() { if (!this.unmounted) ... } componentWillUnmount() { this.unmounted = true }
fatso83
on Nov 11, 2017
|
root
|
parent
[–]
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).
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: