-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Description
Hey,
Looks like nested deriviations override runId without restoring it later, so the runId cannot be used to identify the run. Is it intended?
How to reproduce the issue:
class Store {
get foo() {
console.log('foo', _getGlobalState().runId);
return 'foo';
}
get bar() {
console.log('bar', _getGlobalState().runId);
const foo = this.foo;
console.log('bar', _getGlobalState().runId);
return foo + 'bar';
}
constructor() {
makeAutoObservable(this);
}
}
const store = new Store();
autorun(() => {
console.log('autorun', _getGlobalState().runId);
console.log(store.bar);
console.log('autorun', _getGlobalState().runId);
});
Intended outcome:
autorun 1
bar 2
foo 3
bar 2
foobar
autorun 1
Actual outcome:
autorun 1
bar 2
foo 3
bar 3 // here we see the foo's runId when in fact we're in the same run of bar getter
foobar
autorun 3
Versions
at least the latest one
If you are unable to use CodeSandbox for whatever reasons, please list here all relevant dependencies
If you encounter the issue after upgrading from MobX 4/5 to MobX 6, make sure you've applied the migration guide: https://mobx.js.org/migrating-from-4-or-5.html
-->
Metadata
Metadata
Assignees
Labels
No labels