setState called on unmounted component
Describe the bug In some cases (e.g. when you open the page with GraphView and immediately close it while zoom is still performing) you can get the warning: "Warning: Can't perform a React state update on an unmounted component." In my case this happens in this line: https://github.com/psytechno604/react-digraph/blob/5bc40de33d572af87dc26ac47c0bb809ae99b633/src/components/graph-view.js#L992 and in this line https://github.com/psytechno604/react-digraph/blob/5bc40de33d572af87dc26ac47c0bb809ae99b633/src/components/graph-view.js#L224 (hence, the reason of this is a too fast unmount, within zoomDelay)
To Reproduce Steps to reproduce the behavior:
- Place the GridView on page, set it up with some data that requires zoom on loading
- Open page and immediately go back (within the same React 'context', without page reload)
- See error in console
Expected behavior Should not update state on unmounted component.
I also see this warning in my application. It also seems to happen when zooming is still in progress and the user clicks on something that unmounts the component containing my GraphView.
I suspected it was because the d3 library still has zooms in progress so I searched for "Can't perform a React state update on an unmounted component" d3 cancel zoom and found other d3 users have this problem such as https://github.com/material-components/material-components-web-react/issues/434 . There were some solutions proposed there but I haven't tried them yet. The search mentioned above also led me to a comprehensive analysis and set of recommendations at https://dev.to/jexperton/how-to-fix-the-react-memory-leak-warning-d4i .
I see several cases of asynchronous code in https://github.com/uber/react-digraph/blob/master/src/components/graph-view.js](https://github.com/uber/react-digraph/blob/master/src/components/graph-view.js including d3 zooms, setTimeout, and maybe also the GraphUtils.yieldingLoop. To prevent the warning, all of these would need some sort of cancel mechanism.
Note, the recommendations at https://dev.to/jexperton/how-to-fix-the-react-memory-leak-warning-d4i are based on React Function Components which use React Hooks whereas GraphView is a React class component. From reading https://reactjs.org/docs/hooks-effect.html, it seems that the useEffect React Hook corresponds to the lifecycle callbacks componentDidMount, componentDidUpdate, and componentWillUnmount from React component. So maybe the techniques described in https://dev.to/jexperton/how-to-fix-the-react-memory-leak-warning-d4i can still be used to prevent the warning, but they'll need to be adapted for use by a React class component.