导航器已弃用并已从此包中删除 (expo)

navigator is deprecated and has been removed from this package (expo)

自上次更新以来,我的 expo 项目总是生成错误:导航器已弃用并已从此包中删除。现在可以从 '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 {

   constructor(){
    super()

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

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








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

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

Expo.registerRootComponent(App);

我必须做些什么才能使我的代码再次工作? 提前致谢,

马菲尼乌斯

我相信您应该像下面这样导入和使用它:

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

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

我得到了一个 link,它解决了我同样的错误,所以我想这里也可以。 http://www.hongming.me/?p=670