fix(ui): add 'use client' to sonner Toaster and chart components
Both files use client-only hooks (useTheme in sonner; useState/useMemo/ useId in chart via React) but the shadcn CLI shipped them without the 'use client' directive. Mounting <Toaster /> in the root server layout crashed in production with: Attempted to call useTheme() from the server but useTheme is on the client. Same risk on chart.tsx once any dashboard page renders <Chart>. Verified all of src/components/ui/*.tsx — only these two needed the fix. Future shadcn additions: check 'head -1' for the directive before importing into server components.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import * as RechartsPrimitive from "recharts"
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import { useTheme } from "next-themes"
|
||||
import { Toaster as Sonner, type ToasterProps } from "sonner"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user