So let’s say i have a todoStore. It has an action that deletes a todo by id. Note that i tried both filter and splice: The consuming Todos component(Note that i’m wrapping the Todo with observer): The simple Todo component: Even though i’m clearly mutating(as opposed to constructing a new array) the todos array within the store, Todos component rerenders(i
Tag: mobx
Mobx state updating in console log, but not re-rendering
I’ve created a MobX store (React Native project) and am updating a state value on button click. The state is successfully updating as displayed in a console log, but the DOM is not re-rendering with the updated state. Most answers on SO are a little outdated as they recommend adding @observable in the right places, but the latest MobX docs
Mobx’s observable loses child objects equality
When I create an observable from plain object which contains fields that are effectively same objects, this property are not equal objects anymore. So if I change one’s property, the second stay untouched. Is there a proper way to handle this? https://codesandbox.io/s/mobx-equality-demo-5eowk Answer When you call observable on regular object it does not mutate it, but creates new observable object.
MobX – Why should I use `observer` when I could use `inject` when injecting data into a React component
MobX documentation suggests I should use observer on all my components. However by using inject I get more fine grained control over what data causes a re-rendering of my components. My understanding is I that with observer, a change in all accessed observables in the last render will cause a re-render, even if the observable is nested deep in the
How to get a plain object from mobx object?
I defined a mobx map as below: then I added object on the editors as below: when I get the object from editor as below: the returned object myEditor has some builtin functions such as: I wander how I can get a plain javascript object from editor? Answer You can use toJS. Example