Skip to content
Snippets Groups Projects
useClientContext.ts 414 B
Newer Older
Chif Gergő's avatar
Chif Gergő committed
import { useContext } from 'react';
import { ClientContext } from '../context';
import type { ClientContextType } from '../context';

function useClientContext(): ClientContextType {
  const clientContext = useContext(ClientContext);
  if (!clientContext) {
    throw new Error('You must use `ClientContextProvider` to access the `ClientContext`.');
  }
  return clientContext;
}

export default useClientContext;