Fix networked state update overriding current changes

This commit is contained in:
Mitchell McCaffrey 2021-01-27 07:58:35 +11:00
parent b803f7b4d8
commit 613beff72e

View File

@ -91,7 +91,9 @@ function useNetworkedState(
if (prevState && prevState[partialUpdatesKey] === update.id) {
let newState = { ...prevState };
applyChanges(newState, update.changes);
lastSyncedStateRef.current = newState;
if (lastSyncedStateRef.current) {
applyChanges(lastSyncedStateRef.current, update.changes);
}
return newState;
} else {
return prevState;