2017-05-25 56 views
0

自上次更新以來,我的EXPO項目始終生成以下錯誤:navigator已棄用且已從此軟件包中刪除。它現在可以從'react-native-deprecated-custom-components'而不是'react-native'安裝和導入。在[...]瞭解替代導航解決方案。 enter image description here 但是,當我嘗試從新包中導入它時,我得到錯誤:開發服務器返回響應錯誤代碼:500 [...]。 enter image description here導航器已棄用且已從此軟件包中刪除(EXPO)

我使用expo和下面的代碼。然而,這個錯誤在我想用博覽會創造的每一個新項目中都會遇到。舊項目仍然有效。當我在我的新項目中複製舊代碼時,我得到了與之相同的錯誤。 我認爲代碼是可用的,問題出現在包管理器中。

import Expo from 'expo'; 
 
import React from 'react'; 
 
import {Navigator} from 'react-native-deprecated-custom-components'; 
 
import {Text, View, /*Navigator*/} from 'react-native'; 
 

 
class App extends React.Component { 
 

 
    \t constructor(){ 
 
    \t \t super() 
 

 
    \t // \t this.renderScene = this.renderScene.bind(this) /* bindet die funktion renderScene an das aktuelle this objekt*/ 
 
    \t } 
 

 
    \t renderScene(route, navigator){ 
 
    \t \t if(route.name === 'WelcomePage'){ 
 
    \t \t \t return <WelcomePage navigator={navigator}/> 
 
    \t \t } 
 
    \t \t else if(route.name === 'PlayerSelect'){ 
 
    \t \t  return <PlayerSelect navigator={navigator}/> 
 
    \t } 
 
    \t } 
 

 

 

 

 

 

 

 

 
    render() { 
 
     return (
 
     <View> 
 
     <Navigator 
 
      initialRoute={{name: 'WelcomePage'}} 
 
      renderScene={this.renderScene} 
 
      /> 
 

 
      <Text> Hallo</Text> 
 
     </View> 
 
    ); 
 
    } 
 
    } 
 

 
Expo.registerRootComponent(App);

我有什麼做的,再做我的代碼工作? 由於提前,

Maffinius

+1

爲新項目,我會用反應導航:https://reactnavigation.org – Cruiser

+0

編輯:世博接口輸出該錯誤: 語法錯誤:在分析() 在過程JSON輸入 意外結束。 _tickCallback(internal/process/next_tick.js:103:7) 15:07:09 – Maffinius

回答

2

我相信你應該導入和使用它像以下:

import CustomComponents from 'react-native-deprecated-custom-components'; 

<CustomComponents.Navigator 
    initialRoute={{name: 'WelcomePage'}} 
    renderScene={this.renderScene} 
/> 
+0

考慮你可能需要安裝軟件包:npm我反應了本機棄用的自定義組件 –