mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
updated doc handling hydration mismatch error (#1449)
Co-authored-by: btsb78 <gaurav.pandey@kratikal.com>
This commit is contained in:
parent
691f380dff
commit
ea2868e58e
@ -96,10 +96,18 @@ Add the theme switcher to your app.
|
||||
"use client";
|
||||
|
||||
import {useTheme} from "next-themes";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export const ThemeSwitcher = () => {
|
||||
export function ThemeSwitcher() {
|
||||
const [mounted, setMounted] = useState(false)
|
||||
const { theme, setTheme } = useTheme()
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true)
|
||||
}, [])
|
||||
|
||||
if(!mounted) return null
|
||||
|
||||
return (
|
||||
<div>
|
||||
The current theme is: {theme}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user