October 2019
Intermediate to advanced
426 pages
11h 49m
English
First of all, we have to define a Hook in order to access our own store. As we have learned before, MobX uses React Context to provide, and inject, state into various components. We can get the MobXProviderContext from mobx-react and create our own custom context Hook in order to access all stores. Then, we can create another Hook, to specifically access our TodoStore.
So, let's begin defining a store Hook:
import { useContext } from 'react'import { MobXProviderContext } from 'mobx-react'
export function ...
Read now
Unlock full access