Improve example to avoid memory leak
Closed this issue · 0 comments
acusti commented
The example implementation is fantastic. I found, however, that it sets up a non-cancelable requestAnimationFrame loop in its constructor that will call setState on the component forever, even if it has been unmounted. The loop should be created in componentDidMount
and canceled in componentWillUnmount
, according to the React docs (here and here).