"use client"; import { ThemeProvider as NextThemesProvider } from "next-themes"; import type * as React from "react"; import { useMemo } from "react"; /** สคริปต์ของ next-themes บน client — ค่าคงที่ (ไม่สร้าง object ใหม่ทุก render จน memo ของสคริปต์เสีย) */ const CLIENT_SCRIPT_PROPS = { type: "text/plain" } as const; export type Theme = "light" | "dark" | "system"; /** * ครอบ root layout ครั้งเดียว (ใส่ `suppressHydrationWarning` ที่ ) * ค่าเริ่มต้น: สลับด้วย class `.dark` (ตรง @custom-variant ใน styles.css), ตามระบบ, ไม่กระพริบตอนโหลด * * ```tsx * * {children} * * ``` * * สคริปต์กันกระพริบของ next-themes: render บน server เป็นสคริปต์ปกติ (ทำงานก่อน paint) · บน client ตั้ง `type="text/plain"` * เพราะ React 19 เตือน "Encountered a script tag while rendering React component" เมื่อ client สร้าง `