Skip to content

Handle mutations on detached nodes for stores not relying on useSyncExternalStore #143

@drborges

Description

@drborges

On React versions where useSyncExternalStore is not available, useArbor will track state via a regular useState under the hoods.

When a component is connected to a detached node in the store, updates to that node will cause useArbor to break with a Mutation attempt on a detached node error.

From a user perspective, it would be reasonable to think that components connected to detached nodes would no longer be notified of updates to that node, since it is no longer part of the observable state tree (OST).

To achieve that, we can simply check whether or not the node isDetached in the useArbor implementation and bail when positive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions