Answers for "stateprovider.js react"

0

stateprovider.js react

import React, { createContext, useContext, useReducer } from 'react';

export const StateContext = createContext();

export const StateProvider = ({ reducer, initialState, children }) => (
	<StateContext.Provider value={useReducer(reducer, initialState)}>
		{children}
	</StateContext.Provider>
);

export const useStateValue = () => useContext(StateContext);
Posted by: Guest on June-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language