From 2cb8ba6521f59444680b879e3b343c5bc859df76 Mon Sep 17 00:00:00 2001 From: Warren Seine Date: Thu, 13 Aug 2020 17:20:38 +0200 Subject: [PATCH] add explanation for why we mutate collaborators state (#2028) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🔒 Avoid mutating state * revert to mutation and add explaining comment Co-authored-by: dwelle --- src/components/App.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/App.tsx b/src/components/App.tsx index 3644ffee..ec08b467 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1299,6 +1299,8 @@ class App extends React.Component { username, selectedElementIds, } = decryptedData.payload; + // NOTE purposefully mutating collaborators map in case of + // pointer updates so as not to trigger LayerUI rerender this.setState((state) => { if (!state.collaborators.has(socketID)) { state.collaborators.set(socketID, {});