chore: fix linting errors and ts bugs.
This commit is contained in:
@@ -16,7 +16,9 @@ import { themeLocalStorageKey } from './types'
|
||||
|
||||
export const ThemeSelector: React.FC = () => {
|
||||
const { setTheme } = useTheme()
|
||||
const [value, setValue] = useState('')
|
||||
const [value, setValue] = useState(() =>
|
||||
typeof window === 'undefined' ? 'auto' : window.localStorage.getItem(themeLocalStorageKey) ?? 'auto',
|
||||
)
|
||||
|
||||
const onThemeChange = (themeToSet: Theme & 'auto') => {
|
||||
if (themeToSet === 'auto') {
|
||||
@@ -28,10 +30,6 @@ export const ThemeSelector: React.FC = () => {
|
||||
}
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
const preference = window.localStorage.getItem(themeLocalStorageKey)
|
||||
setValue(preference ?? 'auto')
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<Select onValueChange={onThemeChange} value={value}>
|
||||
|
||||
Reference in New Issue
Block a user