我正在使用 React-native 构建本机应用程序,并且正在使用 React-navigation 进行导航。在主屏幕上,我有一个帖子列表。单击帖子并返回效果很好。但是,用户可以将帖子添加到收藏夹列表。当用户前往 FavScreen 查看收藏帖子列表并单击帖子时,Back 按钮将用户返回到 HomeScreen。显然它应该将用户返回到 FavScreen。这是我的代码:
export const Navigation = StackNavigator({
Home: { // List of all posts
screen: HomeScreen,
navigationOptions: {
title: 'POSTS',
}
},
Post: { // Single post screen
screen: PostDetailsScreen,
navigationOptions: ({ navigation }) => ({
title: navigation.state.params.postDetails.title,
})
},
});
export const TabsNavigation = TabNavigator({
Home: { // List of posts tab
screen: Navigation,
navigationOptions: {
tabBarLabel: 'POSTS',
}
},
Fav: { // List of all favourite posts tab
screen: PostsFavScreen,
navigationOptions: {
tabBarLabel: 'FAVOURITES',
}
}
});
我需要帮助才能找到从帖子点击返回时返回 FavScreen 的方法。谢谢!