mobx-state-tree
mobx-state-tree copied to clipboard
Destroying a model with a preprocessor that returns a new object triggers onSnapshot
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-todolist-0upfe?file=/index.js
Describe the expected behavior
It should destroy the model and not trigger a new onSnapshot
Describe the observed behavior
It triggers a new onSnapshot. This is fixed if the preProcessor returns the inputted snapshot.
As a corollary, the snapshot processor is triggered multiple times, which is not expected behaviour. It should only be processed once. On create/destroy with undefined it is triggered 2x, and on edit it is triggered 3x.
Hey @garrettg123 - thank you for the reproduction of this and the good investigation! I am going to label this as a bug, and hopefully we'll find someone to take it on, or get it on a roadmap somewhere for improvement.
If you're interested in pitching in, let me know! But since it's been almost three years, totally understand if you have since moved on. I appreciate your time one way or another!