I have the following class
export default class BaseStore {
@observable model ;
@action updateStore(propertyName, newValue) {
this.model[propertyName] = newValue;
}
}
In child classes I add layers to the observable model, such as :
model.payment.type = 'credit card'
My react component doesn't render automatically when this happen, it does however, if I has a top level data such as:
model.Type = 'CreditCard'
I am new to MobX, and read that I need to make use of map() but I am unable to find a decent example that explain how to use it.
If you know all the keys that the
model
will have, you can just initialize them with anull
value, and theobserver
components will re-render.Example (JSBin)
If you don't know all the keys of
model
beforehand, you can use a map like you said:Example (JSBin)