未注册反应导航AppRegistry

问题描述 投票:0回答:1

我已经使用react-native init <proj>设置了一个全新的项目,并且构建良好。我在文档之后将react-navigation添加到了项目中。但是,我无法通过此错误:

Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

即使使用其文档中的单个文件堆栈示例:

import React from 'react';
import { View, Text } from 'react-native';
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';

class HomeScreen extends React.Component {
  render() {
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Home Screen</Text>
      </View>
    );
  }
}

const AppNavigator = createStackNavigator({
  Home: {
    screen: HomeScreen,
  },
});

export default createAppContainer(AppNavigator);

它不起作用。我对这里可能出现的问题不知所措,因为我正在使用带有其工作示例的基本安装,并且未添加任何其他内容。我已经尝试了一切,从重新启动捆绑器到清除我能想到的所有缓存。

reactjs react-native react-navigation
1个回答
0
投票

确保您正在注册组件:

const App = createAppContainer(navigator):

AppRegistry.registerComponent(appName, () => App)
© www.soinside.com 2019 - 2024. All rights reserved.