I am want to provider useReducer globally, but createContext() is asking for default value, which is throwing error if I assign null. I have tried assigning empty object instead of null. But I cannot access my userReducer if I do it this way.
import React, { createContext, useContext, useReducer, Dispatch } from "react";
import { reducer, initialState } from "./reducer";
const AppContext = createContext(null)
export const useAppContext = () => useContext(AppContext)
export const AppContextProvider: React.FC = ({children}) => (
<AppContext.Provider value={useReducer(reducer, initialState)}>
{children}
</AppContext.Provider>
)
How can I solve the issue?