|
|
|
|
|
by ramesh31
994 days ago
|
|
>With MobX, this could be done but not with React and not without a bunch of boilerplate that obtains html elements that are referencing the state. It's trivial with MobX. The Observer component essentially gives you an "inline" component wherever you need reactivity, without the need to actually componentize. i.e using a MobX State Tree store: const store = types.model('Store', { value: types.string }).create({value:'But I will!'});
const Page = () => {
return (
<div>
<div><h1>I won't rerender</h1></div>
<Observer>
{()=> {
const { value } = store;
return (
<div>{value}</div>
)
}
</Observer>
</div>
)
}
|
|
Observer component is so simple. Just a deferred function invoke. Could have been done with 2016 primitives too.