Reactjs 反应导航:在每个屏幕中包括一个组件
我正在使用Reactjs 反应导航:在每个屏幕中包括一个组件,reactjs,react-native,react-navigation,Reactjs,React Native,React Navigation,我正在使用StackNavigator和redux一起使用,如下所示。将组件包含到我的所有屏幕中的最干净方式是什么?我尝试将子组件添加到AppWithNavigationState和AppNavigator中,但没有成功 <Provider store={store}> <AppWithNavigationState /> </Provider> const AppNavigator = StackNavigator({ Login: { scree
StackNavigator
和redux
一起使用,如下所示。将组件
包含到我的所有屏幕中的最干净方式是什么?我尝试将子组件添加到AppWithNavigationState
和AppNavigator
中,但没有成功
<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);
const AppNavigator=StackNavigator({
登录:{屏幕:登录},
Main:{screen:Main},
}, {
headerMode:“无”,
}
})
const AppWithNavigationState=({调度,路由器})=>{
返回(
)
};
常量mapStateToProps=(状态)=>({
国家,,
});
导出默认连接(MapStateTops)(AppWithNavigationState);
您可以尝试添加同级组件,而不是添加子组件。试试下面的例子
示例
const AppWithNavigationState = ({ dispatch, router }) => {
return(
<View>
<AppNavigator navigation={addNavigationHelpers({ dispatch, state: router })} />
<DefaultComponentForEachScreen />
</View>
)
};
const-AppWithNavigationState=({dispatch,router})=>{
返回(
)
};
您可以尝试添加同级组件,而不是添加子组件。试试下面的例子
示例
const AppWithNavigationState = ({ dispatch, router }) => {
return(
<View>
<AppNavigator navigation={addNavigationHelpers({ dispatch, state: router })} />
<DefaultComponentForEachScreen />
</View>
)
};
const-AppWithNavigationState=({dispatch,router})=>{
返回(
)
};