import React , { createContext , useContext } from 'react' ; import { AppDependencies } from '../types' ; export const AppContext = createContext < AppDependencies | undefined > ( undefined ) ; export const AppContextProvider = ( { children , value , } ) => { return < AppContext . Provider value = { value } > { children } < /AppContext.Provider>; } ; export const useAppContext = ( ) => { const ctx = useContext ( AppContext ) ; if ( ! ctx ) { throw new Error ( 'useAppContext must be called from inside AppContext' ) ; } return ctx ; } ;