| 1 |
import { createContext, useReducer } from 'react'; |
| 2 |
import AppReducer from './AppReducer'; |
| 3 |
import initialState from './initialState'; |
| 4 |
|
| 5 |
export const AppContext = createContext(); |
| 6 |
|
| 7 |
export const AppProvider = ({ children }) => { |
| 8 |
const [state, dispatch] = useReducer(AppReducer, initialState); |
| 9 |
|
| 10 |
return ( |
| 11 |
<AppContext.Provider value={{ state, dispatch }}> |
| 12 |
{children} |
| 13 |
</AppContext.Provider> |
| 14 |
); |
| 15 |
}; |
| 16 |
|