tldraw/hooks/useTheme.ts

13 lines
323 B
TypeScript
Raw Normal View History

2021-05-14 22:56:41 +00:00
import { useCallback } from "react"
import state, { useSelector } from "state"
export default function useTheme() {
const theme = useSelector((state) =>
2021-05-17 21:27:18 +00:00
state.data.settings.isDarkMode ? "dark" : "light"
2021-05-14 22:56:41 +00:00
)
const toggleTheme = useCallback(() => state.send("TOGGLED_THEME"), [])
return { theme, toggleTheme }
}