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:
nxtkofi 2026-04-21 20:52:52 +02:00
parent a1e653bbf7
commit eec41123ef

View file

@ -1,14 +1,14 @@
"use client"; "use client";
import { useTheme } from "@wrksz/themes/client"; import { useTheme } from "@wrksz/themes/client";
import { useEffect, useState } from "react"; import { useSyncExternalStore } from "react";
export const ThemeChanger = () => { export const ThemeChanger = () => {
const { theme, setTheme } = useTheme(); const { theme, setTheme } = useTheme();
const [mounted, setMounted] = useState(false); const mounted = useSyncExternalStore(
() => () => undefined,
useEffect(() => { () => true,
setMounted(true); () => false,
}, []); );
if (!mounted) { if (!mounted) {
return <p>Loading theme...</p>; return <p>Loading theme...</p>;