import React, {createContext, useContext, useReducer} from 'react'; const initialState = {user: {auth: false}}; const reducer = (state, action) => { console.log(state, action); switch (action.type) { case 'login': return { ...state, user: action.user } case 'logout': return { ...state, user: action.user } default: return state; } }; export const StateContext = createContext(null); export const StateProvider = ({children}) => { return ( {children} ); } export const useStateValue = () => useContext(StateContext);