I use a DrawerNavigator
from react-navigation in my app. Without any customization, the Android status bar is blue, and not black.
I tried to do
StatusBar.setBackgroundColor('#000000');
but it only works for a few seconds, and then it goes back to blue. It seems that something I am using set the status bar color to blue. However, I tried to remove all dependencies and only keep react-navigation, and it still happens and the docs of react-navigation do not say anything about that.
How can I set the status bar color to black with react-navigation ?
I don't think there is any conflict between react-navigation
and the StatusBar
, but I think you should use the <StatusBar>
component rather than the imperative API. There's a high chance this is due to a re-render of your app and it just switch back to the default, with a component declare, you ensure it won't happen.
<StatusBar backgroundColor='blue' barStyle='light-content' />
You can even have multiple ones per route, to change it depending on the path. If you want to change it depending on the user and using redux
, declare it in a connected component and pass the backgroundColor
.