mobx-state-tree
mobx-state-tree copied to clipboard
Use getTime() to check for Date equality
Bug report
A new snapshot is created for the same Date.getTime()
but different Date
object.
Sandbox link or minimal reproduction code
https://github.com/JEFuller/mobx-state-tree/blob/7d8c20321959e51a0607b4a524f407b400a7a92b/packages/mobx-state-tree/tests/core/date.test.ts#L47-L57
Describe the expected behavior
MobX-State-Tree is smart enough to know two Date
are the same because:
-
This is almost certainly what the user wants, and:
-
The value in the JSONPatch is stored as the
getTime()
anyway (so, you can end up with multiple identicalreplace
patches, which doesn't make sense semantically).
Describe the observed behavior
MobX-State-Tree creates a new snapshot every time.