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