UNPKG

@kadconsulting/dry

Version:
16 lines (15 loc) 629 B
import { useContext } from 'react'; import { ThemeContext } from './ThemeProvider'; /** Custom hook that allows access to the ThemeContext. Must be used within a ThemeProvider. @throws Will throw an error if not used within a ThemeProvider. @returns The ThemeContextValue from the context. */ export const useTheme = () => { const themeContext = useContext(ThemeContext); if (themeContext === undefined) throw new Error('useTheme must be used within a ThemeProvider. Did you forget to wrap your application in a ThemeProvider component?'); return themeContext; }; //# sourceMappingURL=useTheme.js.map