October 2019
Intermediate to advanced
426 pages
11h 49m
English
Now, we are going to define the context provider in our src/App.js file, which is going to get the values from the existing Reducer Hook.
Let's define the context provider for global state now:
import { ThemeContext, StateContext } from './contexts'
return ( <StateContext.Provider value={{ state, dispatch }}> <ThemeContext.Provider value={theme}> ... </ThemeContext.Provider> </StateContext.Provider> )
Now, our context provider provides the state object and the dispatch function to the rest of our app, and we can move on to consuming the context ...
Read now
Unlock full access