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

时间:2017-05-23 05:50:55

标签: javascript react-native url-routing

这是我的代码:

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);

当我运行它时,会抛出此错误:

enter image description here

首先,为什么Navigator在最新版本中已被弃用?我现在该怎么办?我几乎不认为安装一个被弃用的东西是个好主意。

1 个答案:

答案 0 :(得分:1)

忘掉导航器,使用react-navigation。

link:https://reactnavigation.org