Skip to content

Commit

Permalink
Update theme in HookLoaderComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
ryota-murakami committed Dec 2, 2023
1 parent d107660 commit 793cde3
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/HeadlessComponents/GrobalHooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ import { useAppSelector } from '../redux/hooks'
import { dispatch } from '../redux/store'
import { selectTheme, updateTheme } from '../redux/themeSlice'

const HookLoaderComponent: HeadlessEffectComponent = memo(() => {
// apply TailwindCSS theme onLoaded
// bause Routes component render phase defenitelly run once per app loding
const theme = useAppSelector(selectTheme)
useIsomorphicEffect(() => {
dispatch(updateTheme(theme))
}, [])
const HookLoaderComponent: HeadlessEffectComponent = memo(
() => {
// apply TailwindCSS theme onLoaded
// bause Routes component render phase defenitelly run once per app loding
const theme = useAppSelector(selectTheme)
useIsomorphicEffect(() => {
dispatch(updateTheme(theme))
}, [])

return null
})
return null
},
() => true,
)
HookLoaderComponent.displayName = 'HeadlessEffect.HookLoaderComponent'

export default HookLoaderComponent

0 comments on commit 793cde3

Please sign in to comment.