Skip to content

mobx6 and makeAutoObservable produce strict mode warnings #2901

Answered by urugator
FalkNisius asked this question in General
Discussion options

You must be logged in to vote

The point of the warning is to avoid missing batch, consider:

autorun(() => {
  console.log(observableObject.a, observableObject.b)
})

setTimeout(() => {
  observableObject.a = 2 // first autorun invocation
  observableObject.b = 2 // second autorun invocation
}, 1500)
// VS 
setTimeout(() => {
  runInAction(() => {    
    observableObject.a = 2
    observableObject.b = 2
  })  
  // one autorun invocation at the end of action (outermost if nested)
}, 1500)

There is no way for us to distinguish between setting one or multiple props. (Potentially is, but it's not reasonable)
If you don't like this behavior, you can turn it off with configure({ requireActions: "never" })
You're expected t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by FalkNisius
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants