Replace empty components with hooks (#666)

This commit is contained in:
mrdrogdrog 2020-10-12 22:33:23 +02:00 committed by GitHub
parent 9e9108ec9a
commit 0d2c2fe0ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 24 deletions

View file

@ -0,0 +1,18 @@
import { useEffect } from 'react'
import { useSelector } from 'react-redux'
import { ApplicationState } from '../../redux'
export const useApplyDarkMode = ():void => {
const darkModeActivated = useSelector((state: ApplicationState) => state.darkMode.darkMode)
useEffect(() => {
if (darkModeActivated) {
window.document.body.classList.add('dark')
} else {
window.document.body.classList.remove('dark')
}
return () => {
window.document.body.classList.remove('dark')
}
}, [darkModeActivated])
}