Creacion de contexto base
This commit is contained in:
11
src/services/State.jsx
Normal file
11
src/services/State.jsx
Normal 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);
|
||||
Reference in New Issue
Block a user