小编Mic*_*kiy的帖子

react-native-tab-view 从反应导航屏幕跳转到特定选项卡

我有 2 个用于导航的库。React 导航 v5 和 React-native-tab-view。反应导航中的 3 个选项卡:主页/发现/个人资料。Discover 是一个具有反应本机选项卡视图的屏幕。我的主页中有几个按钮,按下它们后,它们应该导航到“发现”选项卡和选项卡视图中的特定选项卡。现在,我使用反应导航进行了从“主页”到“发现”的导航。但是,导航到“发现”后如何跳转到特定选项卡?

这是主页中的一个元素,其中包含将我从主页导航到发现的按钮:

render() {
    const { error, pending, refresh, videos } = this.props;

    return (
      <HomeViewItem
        headerText={'Top Videos'}
        footerText={'More Videos'}
        navigate={() =>
          this.props.navigation.navigate('TabNavigator', {
            screen: 'Discover',
          })  // this will navigate me to Discover
        }
        view={this._renderVideos(videos, pending, error, refresh)}
      />
    );
  }
Run Code Online (Sandbox Code Playgroud)

这是“发现”屏幕中的选项卡视图:

export default class DiscoverTabView extends React.Component<DiscoverProps> {
  _StreamsRoute = () => <StreamsTabScreen navigation={this.props.navigation} />;
  _NewsRoute = () => <NewsTabScreen navigation={this.props.navigation} />;
  _VideosRoute = () => <VideosTabScreen navigation={this.props.navigation} />; …
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-native-tab-view react-navigation-v5

1
推荐指数
1
解决办法
5911
查看次数