Z
Z
zwezew2019-02-26 10:39:43
React
zwezew, 2019-02-26 10:39:43

How to pass data through MobX to component's children?

I started to study MobX on this resource, the question arose.
In the example, data is entered into MobX as follows

const appState = observable({
  count: 0
})
appState.increment = function () {
  this.count++;
}
appState.decrement = function () {
  this.count--;
}

Then placed in a component call ReactDOM.render(< Counter store={appState} / >, rootElement);
and I can call it in the child via this.props.store.
And if you need to call it, for example, at the 3rd nesting level? Those. do I need to pass this.props.store to each child component?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-02-26
@zwezew

I started to study MobX on this resource, the question arose.

So you study further - the answer to your question is in the eighth part of this guide.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question