I've tried using Appearence.addChangeListener withing an useEffect hook in React native to detect changes in system Light/Dark mode, but in Android the listener isn't called when I switch Light/Dark mode via system settings, but it works fine in IOS.
const listener = () => { console.log('called appearence change'); dispatch(switchColorScheme()) }; useEffect(()=>{ Appearance.addChangeListener(listener) },[])
How do I make my android app (Appearance API works fine in my IOS app) change color scheme dynamically as the Dark/Light mode is toggled in system settings
To reproduce the issue:
- Create a react native app with typescript template: npx react-native init MyApp --template react-native-template-typescript
- Call
Appearance.AddChangeListener (() => {console.log ("Appearance changed")})
within an useEffect hook - Running it in an android device will not log Appearance changed, but it will log the same in an IOS device