fix theme switching on web without refresh

zio/stable
Eric Bailey 2023-09-14 12:55:47 -05:00
parent b9268d503a
commit a88ac217c2
1 changed files with 5 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import {isWeb} from 'platform/detection'
import React, {ReactNode, createContext, useContext} from 'react'
import {
AppState,
@ -101,6 +102,10 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({
React.useState<ColorSchemeName>(colorSchemeFromRN)
React.useEffect(() => {
if (isWeb) {
setNativeColorScheme(colorSchemeFromRN)
}
const subscription = AppState.addEventListener('change', state => {
const isActive = state === 'active'