Browse Source

Update packages/ui/src/components/theme-provider.tsx

Co-authored-by: Copilot <[email protected]>
pull/900/head
Dan Ditomaso 8 months ago
committed by GitHub
parent
commit
2c45480dc5
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      packages/ui/src/components/theme-provider.tsx

5
packages/ui/src/components/theme-provider.tsx

@ -66,8 +66,9 @@ export function ThemeProvider({
export const useTheme = () => {
const context = useContext(ThemeProviderContext)
if (context === undefined)
throw new Error("useTheme must be used within a ThemeProvider")
// If the provider is missing, context will be initialState (setTheme is a no-op)
if (context.setTheme === initialState.setTheme)
throw new Error("useTheme must be used within a ThemeProvider: provider is missing")
return context
}

Loading…
Cancel
Save