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";
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>;