【发布时间】:2017-12-22 00:55:17
【问题描述】:
我有用户列表,每个用户在列表中都有自己的显示图像。
我正在尝试的是,每当用户按下显示图像时,通过 stackNavigation 重定向到他/她的个人资料。
自定义标签视图:
const CustomTabView = ({ router, navigation }) => {
const { routes, index } = navigation.state;
const ActiveScreen = router.getComponentForState(navigation.state);
const routeNav = addNavigationHelpers({
...navigation,
state: routes[index],
});
const routeOptions = router.getScreenOptions(routeNav, 'tabBar');
return (
<View style={styles.container}>
<CustomTabBar
navigation={navigation}
activeRouteName={routes[index].routeName}
icon={routeOptions.tabBarIcon}
/>
<ActiveScreen
navigation={addNavigationHelpers({
...navigation,
state: routes[index]
})}
/>
</View>
);
};
StackNavigator: // goToProfile.js // 也尝试放入 index.anndroid.js 但没有找到导出方法
const goToProfile = StackNavigator({
Profile: {
screen: Profile,
navigationOptions: ({ navigation }) => ({
title: `${navigation.state.params.person.name.first} ${navigation.state.params.person.name.last}`
})
},
})
自定义标签: //index.android.js
const CustomTabRouter = TabRouter(
{
Chat: {
screen: Chats,
path: ""
},
Status: {
screen: Contacts,
path: "notifications"
},
Camera: {
screen: Camera,
path: "settings"
}
},
{
initialRouteName: "Chat",
},
);
const CustomTabs = createNavigationContainer(
createNavigator(CustomTabRouter)(CustomTabView)
);
也是我的组件:
<TouchableOpacity
onPress = { () => this.props.navigation.navigate('Profile', { item } ) } >
<Avatar
source={{ uri: item.picture.thumbnail }}
/>
</TouchableOpacity>
【问题讨论】:
-
有什么问题?
-
@Cruiser 如何在我的聊天屏幕中使用 stacknavigator 来实现这一目标
-
SO 不是代码编写服务。我建议您尝试一下,并在遇到问题、遇到错误或遇到其他问题时提出问题
-
@Cruiser 哈哈,我知道,我尝试了不同的方法,没有成功
-
@Cruiser 我尝试使用 stacknavigator const 在聊天屏幕中包含
chats { screen: goToProfile }
标签: reactjs react-native react-native-android react-navigation