Altering an observed value. #204
-
I have an observed value from a model prop. It's frozen, and any changes to it result in an error (great!). However, I wish to clone it and alter the object. What's the best way of doing that? Right now my solution is... kind gross.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can clone using the clone function: https://mobx-keystone.js.org/snapshots#clonet-extends-objectvalue-t-options-cloneoptions-t Then to alter it you can either use your own custom modelAction, runUnprotected (although not usually recommended since it wouldn't be recorded as an ation) or any of the predefined fnObject functions (if you don't want to create your own): https://mobx-keystone.js.org/functionalModels#predefined-fnobject-and-fnarray |
Beta Was this translation helpful? Give feedback.
You can clone using the clone function:
https://mobx-keystone.js.org/snapshots#clonet-extends-objectvalue-t-options-cloneoptions-t
Then to alter it you can either use your own custom modelAction, runUnprotected (although not usually recommended since it wouldn't be recorded as an ation) or any of the predefined fnObject functions (if you don't want to create your own):
https://mobx-keystone.js.org/functionalModels#predefined-fnobject-and-fnarray