Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing calls to setState after unmount (ReactTraining#139)
Issue ReactTraining#139 was the same issue I was having when resizing a window. I was receiving an error about a possible memory leak since setState was called on an unmounted component. It seems like the `getMatches` call was taking just long enough that the component could be unmounted while it was executing. By using a `_mounted` flag, we can determine if it is safe to call `setState` and bypass it if the component is unmounted. I looked at using an abort signal, but I don't think the `matchMedia` API is robust enough for that currently.
- Loading branch information