tldraw/hooks/useTheme.ts
2021-05-14 23:56:41 +01:00

12 lines
321 B
TypeScript

import { useCallback } from "react"
import state, { useSelector } from "state"
export default function useTheme() {
const theme = useSelector((state) =>
state.data.settings.darkMode ? "dark" : "light"
)
const toggleTheme = useCallback(() => state.send("TOGGLED_THEME"), [])
return { theme, toggleTheme }
}