I havenβt done a lot of mobs lately and havenβt tested this, but as a rule, you would have a provider somewhere, and then use @injectfor transferring storages as details
Consumer Information:
import { observer, inject } from 'mobx-react'
@inject('information')
@observer
class Information extends React.Component {
render(){
{this.props.information.foo}
}
}
model level is very simple
import { observable, action } from 'mobx'
class Information {
@observable foo = 'bar'
@action reset(){
this.foo = 'foo'
}
}
export new Information()
Root provider level
import { Provider } from 'mobx-react'
import Information from ./information'
<Provider information={Information}>
<Information />
</Provider>
// test it...
setTimeout(() => {
Information.foo = 'back to foo'
}, 2000)
, , ,
context childContextType contextType, HOC props.