UNPKG

@crossed/styled

Version:

A universal & performant styling library for React Native, Next.js & React

24 lines (23 loc) 589 B
"use client"; import { useEffect, useState, useTransition } from "react"; import { Registry } from "./Registry"; import { isWeb } from "./isWeb"; const useTheme = () => { const [theme, setTheme] = useState( Registry.getTheme(isWeb) ); const [, setTransition] = useTransition(); useEffect(() => { const unsubscribe = Registry.subscribe(() => { setTransition(() => setTheme(Registry.getTheme(isWeb))); }); return () => { unsubscribe(); }; }, [setTheme, setTransition]); return theme; }; export { useTheme }; //# sourceMappingURL=useTheme.js.map