Reputation: 4088
I'm using a StackNavigator
with redux
like below. What is the cleanest way to include a Component
to all my screens? I've tried adding a child Component
to both AppWithNavigationState
and AppNavigator
with no luck.
<Provider store={store}>
<AppWithNavigationState />
</Provider>
const AppNavigator = StackNavigator({
Login: { screen: Login },
Main: { screen: Main },
}, {
headerMode: 'none',
}
})
const AppWithNavigationState = ({ dispatch, router }) => {
return(
<AppNavigator navigation={addNavigationHelpers({ dispatch, state: router })} />
)
};
const mapStateToProps = (state) => ({
state,
});
export default connect(mapStateToProps)(AppWithNavigationState);
Upvotes: 0
Views: 138
Reputation: 24670
You can try to add a sibling component rather than adding a child component. Try the example below.
Example
const AppWithNavigationState = ({ dispatch, router }) => {
return(
<View>
<AppNavigator navigation={addNavigationHelpers({ dispatch, state: router })} />
<DefaultComponentForEachScreen />
</View>
)
};
Upvotes: 2