text: import React, { useReducer, createContext } from "react"
  
  export const GlobalStateContext = createContext()
  export const GlobalDispatchContext = createContext()
  
  const initialState = {
    lightMode: true,
  }
  
  function reducer(state, action) {
    switch (action.type) {
      case "TOGGLE_DARK_MODE": {
        return {
          ...state,
          lightMode: !state.lightMode,
        }
      }
      default:
        throw new Error("Bad Action Type")
    }
  }
  
  const GlobalContextProvider = ({ children }) => {
    const [state, dispatch] = useReducer(reducer, initialState)
    return (
      <GlobalStateContext.Provider value={state}>
        <GlobalDispatchContext.Provider value={dispatch}>
          {children}
        </GlobalDispatchContext.Provider>
      </GlobalStateContext.Provider>
    )
  }
  
  export default GlobalContextProvider
  