I am trying React with MobX.
I defined fetchSources() in my store.
If I put the following at the top level component it works fine.
componentWillMount() {
this.props.store.fetchSources()
}
But if I put the above same code into child level component which is also defined as an observer it gives me the following error.
TypeError: Cannot read property 'fetchSources' of undefined.
Any idea as to how to fix it?
Update:
Tholle is correct. The problem is resolved by passing the store to the child component.
Make sure you pass the fetchSources as a prop to the child component as well, and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With