Browse Source

add explanation for why we mutate collaborators state (#2028)

* 🔒 Avoid mutating state

* revert to mutation and add explaining comment

Co-authored-by: dwelle <luzar.david@gmail.com>
Warren Seine 4 years ago
parent
commit
2cb8ba6521
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/components/App.tsx

+ 2 - 0
src/components/App.tsx

@@ -1299,6 +1299,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
                 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, {});