Fix unmounting of inbox view

This commit is contained in:
Evan Hahn 2021-06-16 17:16:08 -05:00 committed by GitHub
parent 4b6352b345
commit dfa6fb5d61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,11 +29,11 @@ export const Inbox = ({ hasInitialLoadCompleted }: PropsType): JSX.Element => {
viewRef.current = view; viewRef.current = view;
return () => { return () => {
if (!viewRef || !viewRef.current) { // [`Backbone.View.prototype.remove`][0] removes the DOM element and stops listening
return; // to event listeners. Because React will do the first, we only want to do the
} // second.
// [0]: https://github.com/jashkenas/backbone/blob/153dc41616a1f2663e4a86b705fefd412ecb4a7a/backbone.js#L1336-L1342
viewRef.current.remove(); viewRef.current?.stopListening();
viewRef.current = undefined; viewRef.current = undefined;
}; };
}, []); }, []);