commerce/site/lib/hooks/useToggleTheme.ts
Catalin Pinte 6d783eae35
Footer theme switcher (#894)
* Footer theme switcher

* Remove lazy loading & change rotation animation

* Changes

* Update ThemeSwitcher.tsx

* Requested style changes

* Update ThemeSwitcher.tsx

* Fix alignment

* Update ThemeSwitcher.tsx
2022-11-30 10:07:44 -05:00

12 lines
338 B
TypeScript

import { useTheme } from 'next-themes'
import { useEffect, useState } from 'react'
export const useToggleTheme = () => {
const { theme, themes, setTheme } = useTheme()
const [themeValue, setThemeValue] = useState<string>('system')
useEffect(() => setThemeValue(theme), [theme])
return { theme: themeValue, setTheme, themes }
}