-
Greetings! I have a store class, configured strictly, and observable array in it (TodoStore in the example). I use the observable array in a function inside an observer wrapped component, and get the "[mobx] Observable being read outside a reactive context." (TodoList in example) I would prefer to use strictly configured store. Is it any right way to do so without getting that warning? Example below doesn't reproduce my real case, but is enough to reproduce the warning. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You're getting the warning, because |
Beta Was this translation helpful? Give feedback.
You're getting the warning, because
console.log
isn't synchronous, therefore it accessestodos
outsideobserver
.Change it to
console.log(mobx.toJS(todos));
and warning is gone. ThetoJS
will run as part ofobserver
, subscribing totodos
and anything within,console.log
later prints the returned non-observable copy.