From dfa6fb5d6108c38f7908448edb41aee439a29b73 Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Wed, 16 Jun 2021 17:16:08 -0500 Subject: [PATCH] Fix unmounting of inbox view --- ts/components/Inbox.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ts/components/Inbox.tsx b/ts/components/Inbox.tsx index 8619c5413..bfc404f69 100644 --- a/ts/components/Inbox.tsx +++ b/ts/components/Inbox.tsx @@ -29,11 +29,11 @@ export const Inbox = ({ hasInitialLoadCompleted }: PropsType): JSX.Element => { viewRef.current = view; return () => { - if (!viewRef || !viewRef.current) { - return; - } - - viewRef.current.remove(); + // [`Backbone.View.prototype.remove`][0] removes the DOM element and stops listening + // 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?.stopListening(); viewRef.current = undefined; }; }, []);