mobx-state-tree
mobx-state-tree copied to clipboard
safeReference invalidates on old subtree destroying
Bug report
- [X] I've checked documentation and searched for existing issues
- [X] I've made sure my project is based on the latest MST version
- [X] Fork this code sandbox or another minimal reproduction.
Sandbox link or minimal reproduction code https://codesandbox.io/s/mobx-state-tree-broken-reference-example-c7tum
Describe the observed behavior When safeReference points to some model in subtree, then subtree detached and new subtree attached with same id model (here safeReference points to new subtree) and then old subtree destroyed, safeReference will be reset to undefined, but it shouldn't.
Describe the expected behavior If safeReference points to new subtree, then old, already detached, subtree destroying should not affect this reference.
Maybe #1052 is related somehow.
Hey @Amareis - thanks for the issue, and I'm sorry no one got back to you for so long. I'm going to label this as a bug and see if I can work with the maintainers to figure out a solution.
I know it's been years, so if this isn't relevant to you any longer, I totally get it. But if you're interested in helping, I'd be happy to collaborate a little.