Creacion de contexto base

This commit is contained in:
Daniel Cortes
2020-06-22 19:47:09 -04:00
parent 8f9c4e7952
commit 504a37545d
2 changed files with 41 additions and 12 deletions

11
src/services/State.jsx Normal file
View File

@@ -0,0 +1,11 @@
import React, {createContext, useContext, useReducer} from 'react';
export const StateContext = createContext(null);
export const StateProvider = ({reducer, initialState, children}) => (
<StateContext.Provider value={useReducer(reducer, initialState)}>
{children}
</StateContext.Provider>
);
export const useStateValue = () => useContext(StateContext);