-
Hi, I have a simplified mobx state:
And elsewhere in app I call dateMobx.setDateTo in an autorun. I get a warning because autoActions are not untracked. using a setter |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Mutating state as part of autorun(() => {
// yada yada
runInAction(() => {
dateMobx.setDateTo('XXX')
})
})
// or (the effect is implicitly action)
reaction(() => `${foo.year}-${foo.month}-${foo.day}`, dateString => dateMobx.setDateTo(dateString))
|
Beta Was this translation helpful? Give feedback.
Mutating state as part of
autorun/reaction
is discouraged:https://mobx.js.org/reactions.html#use-reactions-sparingly
If you still want to do so I would go with
makeAutoObservable(this, { setDateTo: action });