Skip to content

isolateGlobalState: true can cause conflicts that prevent observable registration #3860

@dbecks

Description

@dbecks

Intended outcome:

A reaction should trigger when a dependent property updates when it's registered after calling configure({ isolateGlobalState: true }).

Actual outcome:

If there are 2 properties that depend on the same shared property then it's possible that a call to configure({ isolateGlobalState: true }) can prevent one of the properties from updating when the shared property updates.

How to reproduce the issue:

Example Code: https://codesandbox.io/p/sandbox/vigorous-grass-j3v27n?file=%2Findex.js

Create an observable with 2 properties (prop1 and prop2 for reference) that both depend on same shared property. Create a reaction on prop1, call configure({ isolateGlobalState: true }), create a reaction on prop2. Change the shared property through an action and notice that only prop1 is updated while prop2 does not update.

Internally, the globalState maintains a runId that is supposed to remain unique. Calling configure will reset the globalState.runId allowing for 2 different ComputedValue to have the same runId_ and prevent registering a listener on a shared observable.

Versions

mobx: 6.1.7, 6.12.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions