File tree Expand file tree Collapse file tree 4 files changed +10
-48
lines changed
Expand file tree Collapse file tree 4 files changed +10
-48
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ import {
1919} from './components'
2020import { ThemeProvider } from './contexts/themeContext'
2121import MainComponent from './components/main/MainComponent'
22- import ThemeComponent from './components/theme/ThemeComponent'
2322import MonacoEnvironmentInitializer from './components/MonacoEnvironmentInitializer/MonacoEnvironmentInitializer'
2423import GlobalDialogs from './components/global-dialogs'
2524import NotFoundErrorPage from './pages/not-found-error/NotFoundErrorPage'
@@ -51,7 +50,6 @@ const App = ({ children }: { children?: ReactElement[] }) => {
5150 } , [ serverLoading ] )
5251 return (
5352 < div className = "main-container" >
54- < ThemeComponent />
5553 < MonacoEnvironmentInitializer />
5654 < Switch >
5755 < Route exact path = { Pages . notFound } component = { NotFoundErrorPage } />
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- import React from 'react'
1+ import React , { useContext } from 'react'
22import { ThemeProvider as StyledThemeProvider } from 'styled-components'
33import {
44 theme as redisUiOldTheme ,
@@ -44,6 +44,10 @@ export const defaultState = {
4444 } ,
4545}
4646
47+ export const isValidTheme = ( theme : unknown ) : theme is Theme => {
48+ return typeof theme === 'string' && THEME_NAMES . includes ( theme as Theme )
49+ }
50+
4751export const ThemeContext = React . createContext ( defaultState )
4852
4953export class ThemeProvider extends React . Component < Props > {
@@ -57,7 +61,7 @@ export class ThemeProvider extends React.Component<Props> {
5761
5862 if ( queryTheme ) {
5963 theme = queryTheme
60- } else if ( storedThemeValue && THEME_NAMES . includes ( storedThemeValue ) ) {
64+ } else if ( storedThemeValue && isValidTheme ( storedThemeValue ) ) {
6165 theme = storedThemeValue
6266 }
6367
@@ -120,5 +124,9 @@ export class ThemeProvider extends React.Component<Props> {
120124 )
121125 }
122126}
127+
128+ export const useThemeContext = ( ) => {
129+ return useContext ( ThemeContext )
130+ }
123131
124132export default ThemeProvider
You can’t perform that action at this time.
0 commit comments