简体   繁体   English

如何在最新版本的React Native中使用Navigator?

[英]How can I use Navigator in the newest version of React Native?

Here is my code: 这是我的代码:

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Navigator
} from 'react-native';

import Component5 from './app/components/component5/component5.js';
import Component6 from './app/components/component6/component6.js';

export default class myproject extends Component {
  renderScene(route, navigator){
    switch(route.id){
      case 'component5':
        return(<Component5 navigator={navigator} title="component5" />)
      case 'component6':
        return(<Component6 navigator={navigator} title="component6" />) 
    }
  }

  render() {
    return (
      <Navigator
        initialRoute={{id:'component5'}}
        renderScene={this.renderScene}
        configureScreen={(route, routeStack) => Navigtator.SceneConfigs.FloatFromBottom}
      />
    );
  }
}


AppRegistry.registerComponent('myproject', () => myproject);

When I run it, it throws this error: 当我运行它时,它将引发以下错误:

在此处输入图片说明

First of all, why Navigator is deprecated in the latest version? 首先,为什么不建议使用最新版本的Navigator And what should I do now? 我现在该怎么办? I hardly think installing a deprecated thing be a good idea. 我几乎认为安装不赞成使用的东西不是一个好主意。

Forget about navigator, use react-navigation. 忘记导航器,使用react-navigation。

link: https://reactnavigation.org 链接: https//reactnavigation.org

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM