mobx-state-tree icon indicating copy to clipboard operation
mobx-state-tree copied to clipboard

Destroying a model with a preprocessor that returns a new object triggers onSnapshot

Open garrettg123 opened this issue 5 years ago • 2 comments

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.

garrettg123 avatar Jul 09 '20 00:07 garrettg123

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.

garrettg123 avatar Jul 09 '20 02:07 garrettg123

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!

coolsoftwaretyler avatar Jun 30 '23 04:06 coolsoftwaretyler