refactor(theme): use useSyncExternalStore for theme hydration
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
a1e653bbf7
commit
eec41123ef
1 changed files with 6 additions and 6 deletions
|
|
@ -1,14 +1,14 @@
|
|||
"use client";
|
||||
import { useTheme } from "@wrksz/themes/client";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useSyncExternalStore } from "react";
|
||||
|
||||
export const ThemeChanger = () => {
|
||||
const { theme, setTheme } = useTheme();
|
||||
const [mounted, setMounted] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
}, []);
|
||||
const mounted = useSyncExternalStore(
|
||||
() => () => undefined,
|
||||
() => true,
|
||||
() => false,
|
||||
);
|
||||
|
||||
if (!mounted) {
|
||||
return <p>Loading theme...</p>;
|
||||
|
|
|
|||
Loading…
Reference in a new issue