2017-05-23 82 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)中鏈接的那個? –

相關問題