1import React, { createContext, useContext, useReducer } from 'react';
2
3export const StateContext = createContext();
4
5export const StateProvider = ({ reducer, initialState, children }) => (
6 <StateContext.Provider value={useReducer(reducer, initialState)}>
7 {children}
8 </StateContext.Provider>
9);
10
11export const useStateValue = () => useContext(StateContext);
12