2017-05-23 41 views
0

这里是我的代码:如何在最新版本的React Native中使用Navigator?

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

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

链接:https://reactnavigation.org

+0

我明白了,谢谢,upvote。你对“路由器通量”有什么看法? –

+0

嗨,我无法对路由器通量发表任何评论,因为我之前没有使用它。但如果你想找到一个新的导航解决方案,我会推荐react-navigation。这是一种“官方”导航解决方案,用于反应原生且相当稳定。 – KimHau

+0

啊,正是你的意思*反应导航*正好?你在你的问题或[this](https://github.com/wix/react-native-navigation)中链接的那个? –

相关问题