1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2025-02-18 13:29:36 +01:00

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>
This commit is contained in:
Warren Seine 2020-08-13 17:20:38 +02:00 committed by GitHub
parent 5670c47789
commit 2cb8ba6521
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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, {});