-
Notifications
You must be signed in to change notification settings - Fork 639
Description
Bug report
- I've checked documentation and searched for existing issues and discussions
- I've made sure my project is based on the latest MST version
- Fork this code sandbox or another minimal reproduction.
Sandbox link or minimal reproduction code
Describe the expected behavior
When a component is defined as bellow, where item prop is a MST Node, if that node changes the component should update without any issue.
const Comp = ({ item }) => {
return <div>Hello {item?.name}</div>;
};
const CompLaterObserved = observer(Comp);Describe the observed behavior
However, on React 19, the above observer usage pattern spits out errors (one for each property of the node) shown at the end. The component still updates and everything works apparently, but it's annoying and very noisy in the log (especially since it's one per property, so a big model might spint dozens of errors).
If the observer is wrapped directly e.g.
const Comp = observer(({ item }) => { ...});then no errors are shown.
I'm suspecting this might be a mobx issue and not an MST one, but I'm not sure even where to start creating a minimal example of pure mobx error.
Here is an example of an error:
index.js:27 Error: [mobx-state-tree] You are trying to read or write to an object that is no longer part of a state tree. (Object type: 'Item', Path upon death: '/item', Subpath: 'name', Action: ''). Either detach nodes first, or don't use objects after removing / replacing them in the tree.
at warnError (mobx-state-tree.module.js:3811:16)
at ObjectNode.value (mobx-state-tree.module.js:1932:13)
at ObjectNode.value (mobx-state-tree.module.js:2026:12)
at ObservableValue.dehanceValue (mobx.esm.js:1695:19)
at ObservableValue.get (mobx.esm.js:1751:17)
at ObservableObjectAdministration.getObservablePropValue_ (mobx.esm.js:4782:34)
at Object.get [as name] (mobx.esm.js:5188:26)
at ObservableObjectAdministration.get_ (mobx.esm.js:4832:24)
at Object.get (mobx.esm.js:3518:27)
at addObjectDiffToProperties (react-dom-client.development.js:3968:25)
at addObjectDiffToProperties (react-dom-client.development.js:4016:23)
at logComponentRender (react-dom-client.development.js:4130:22)
at commitPassiveMountOnFiber (react-dom-client.development.js:15469:13)
at recursivelyTraversePassiveMountEffects (react-dom-client.development.js:15439:11)
at commitPassiveMountOnFiber (react-dom-client.development.js:15718:11)
at recursivelyTraversePassiveMountEffects (react-dom-client.development.js:15439:11)
at commitPassiveMountOnFiber (react-dom-client.development.js:15476:11)
at recursivelyTraversePassiveMountEffects (react-dom-client.development.js:15439:11)
at commitPassiveMountOnFiber (react-dom-client.development.js:15718:11)
at recursivelyTraversePassiveMountEffects (react-dom-client.development.js:15439:11)
at commitPassiveMountOnFiber (react-dom-client.development.js:15519:11)
at flushPassiveEffects (react-dom-client.development.js:18432:9)
at flushPendingEffects (react-dom-client.development.js:18358:14)
at flushSpawnedWork (react-dom-client.development.js:18323:44)
at commitRoot (react-dom-client.development.js:17955:9)
at commitRootWhenReady (react-dom-client.development.js:16824:7)
at performWorkOnRoot (react-dom-client.development.js:16722:15)
at performSyncWorkOnRoot (react-dom-client.development.js:18972:7)
at flushSyncWorkAcrossRoots_impl (react-dom-client.development.js:18814:21)
at processRootScheduleInMicrotask (react-dom-client.development.js:18853:9)
at eval (react-dom-client.development.js:18991:13)