Setting the value of `mode` in` DarkModeProvider` has no effect.
Closed this issue · 3 comments
kimmy-wang commented
I set the value of mode
in DarkModeProvider
, it has no effect.
DimitarNestorov commented
kimmy-wang commented
But the background color of the main page has not changed.
DimitarNestorov commented
That's because you're using <DarkModeProvider>
in the same place you're already calling hooks. You have two options:
- Extract anything but the
<DarkModeProvider>
andcurrentMode
from the App component in a separate component and call the other hooks there - Just use
currentMode
instead of the hooks like so:
const styles = dynamicStyleSheet[currentMode];
const source = logoUri[currentMode];
const modeSource = modeUri[currentMode];
const barSource = barStyle[currentMode];
const barBGSource = barBGStyle[currentMode];
Hooks are going to work fine in child components either way.