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:
kovakmedya
2026-04-30 05:52:08 +03:00
parent 113988273f
commit add2317717
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -1,3 +1,5 @@
"use client"
import * as React from "react"
import * as RechartsPrimitive from "recharts"
+2
View File
@@ -1,3 +1,5 @@
"use client"
import { useTheme } from "next-themes"
import { Toaster as Sonner, type ToasterProps } from "sonner"