Skip to content

Moving nodes in Collaborative mode. #4136

Closed Answered by chrtze
Kost927 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @Kost927,

we did some digging and found a possible solution for your issue: To prevent changes from being synced between local and remote state, you can change the observer code to distinguish between local and remote updates:

useNodesStateSynced.ts:73

// here we are observing the nodesMap and updating the nodes state whenever the map changes.
useEffect(() => {
  const observer = (_: unknown, transaction: Transaction) => {
    // The idea here is that when the update originates from a local mutation to
    // the `nodesMap`, we want to update the nodes state directly...
    if (transaction.local) {
      setNodes(Array.from(nodesMap.values()));
    }
    // ... but when the change is …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@chrtze
Comment options

Comment options

You must be logged in to vote
1 reply
@Kost927
Comment options

Answer selected by chrtze
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants