Closed annjawn closed 4 years ago
I am not sure i can get it to work. I did
Appearance.addChangeListener
in mycomponentDidMount
and have a state update inside of it but when I change the theme while testing nothing really happens and thecolorScheme
continues to have the previouscolorScheme
value. I am not sure if I am doing this correctly.componentDidMount(){ this._schemeSubscription = Appearance.addChangeListener(({ colorScheme }) => { this.setState({ colorscheme: colorScheme }); }); }
@annjawn How did you manage to fix it?
I missed wrapping the root with <AppearanceProvider>
, once I did that the Appearance.addChangeListener
started working.
with the new useColorScheme()
there is no need for setting state any more,
just use const colortheme= useColorScheme()
and use colortheme anywhere
What is I need to find color scheme outside the functional component?
I am not sure i can get it to work. I did
Appearance.addChangeListener
in mycomponentDidMount
and have a state update inside of it but when I change the theme while testing nothing really happens and thecolorScheme
continues to have the previouscolorScheme
value. I am not sure if I am doing this correctly.