stateprovider js react

Solutions on MaxInterview for stateprovider js react by the best coders in the world

showing results for - "stateprovider js react"
Noeline
26 Aug 2018
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