Reputation:
In React Native using react-native-router-flux, How can I set the background color for the whole app and also individual scene as well?
Here is my current set up:
const RouterWithRedux = connect()(Router)
const store = configureStore()
export default class App extends Component {
render() {
return (
<Provider store={store}>
<RouterWithRedux>
<Scene key='root'>
<Scene initial={true} key='login' component={Login} title='Login Page'/>
<Scene key='register' component={Register} title='Register'/>
</Scene>
</RouterWithRedux>
</Provider>
)
}
}
Thank you
Upvotes: 1
Views: 5400
Reputation: 1890
In the API documentation, you can use sceneStyle
or getSceneStyle
on both Router
and Scene
(only getSceneStyle
for Router
though).
EDIT
In the Router
you can only use getSceneStyle
and you must pass a function:
// ..
const getSceneStyle = (/* NavigationSceneRendererProps */ props, computedProps) => {
const style = {
backgroundColor: 'blue',
};
return style;
};
// ..
<Router getSceneStyle={getSceneStyle} {...otherProps}>
// ..
For your Scene
s you can just pass an object or StyleSheet
object to sceneStyle
or use getSceneStyle
(making sure you pass a function like above):
<Scene
key="my-scene"
component={MyScene}
sceneStyle={{
backgroundColor: 'red',
}}
title="My Scene" />
This will override the blue background.
Upvotes: 3