File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 11import React , { Suspense , useEffect } from 'react'
22import { HashRouter , Route , Routes } from 'react-router-dom'
3+ import { useSelector } from 'react-redux'
34
45import { CSpinner , useColorModes } from '@coreui/react'
56import './scss/style.scss'
@@ -14,14 +15,21 @@ const Page404 = React.lazy(() => import('./views/pages/page404/Page404'))
1415const Page500 = React . lazy ( ( ) => import ( './views/pages/page500/Page500' ) )
1516
1617const App = ( ) => {
17- const { setColorMode } = useColorModes ( 'coreui-free-react-admin-template-theme' )
18- const urlParams = new URLSearchParams ( window . location . href . split ( '?' ) [ 1 ] )
18+ const { isColorModeSet , setColorMode } = useColorModes ( 'coreui-free-react-admin-template-theme' )
19+ const theme = useSelector ( ( state ) => state . theme )
1920
2021 useEffect ( ( ) => {
22+ const urlParams = new URLSearchParams ( window . location . href . split ( '?' ) [ 1 ] )
2123 if ( urlParams . get ( 'theme' ) ) {
2224 setColorMode ( urlParams . get ( 'theme' ) )
2325 }
24- } , [ ] )
26+
27+ if ( isColorModeSet ( ) ) {
28+ return
29+ }
30+
31+ setColorMode ( theme )
32+ } , [ ] ) // eslint-disable-line react-hooks/exhaustive-deps
2533
2634 return (
2735 < HashRouter >
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { createStore } from 'redux'
22
33const initialState = {
44 sidebarShow : true ,
5+ theme : 'light' ,
56}
67
78const changeState = ( state = initialState , { type, ...rest } ) => {
You can’t perform that action at this time.
0 commit comments