我正在开始学习React Native开发,但是遇到了一个问题。当我尝试运行我的应用程序时,出现了错误:
Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
Unhandled JS Exception: Invariant Violation: Native module cannot be null.
Unhandled JS Exception: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
我的App.js:
import React, { Component } from 'react';
import { SafeAreaView } from 'react-native';
import DefaultRouter from './src/navigation/DefaultRouter'
export default class App extends Component {
render() {
return (
<SafeAreaView>
<DefaultRouter />
</SafeAreaView>
);
}
};
index.js:
import { AppRegistry } from 'react-native';
import App from './App';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => App);
DefaultRouter.js:
import { createSwitchNavigator, createAppContainer } from 'react-navigation';
import LoginScreen from '../screen/LoginScreen';
import DefaultTabBar from '../navigation/TabBar';
const DefaultRouter = createSwitchNavigator({
LOGIN_SCREEN: {
screen: LoginScreen
},
TAB_NAVIGATION: {
screen: DefaultTabBar
}
}, {
initialRouteName: 'LOGIN_SCREEN',
headerMode: 'none'
})
export default createAppContainer(DefaultRouter)
其他的文件都是简单的
Component
子类。这个问题无论我是从Visual Studio Code运行应用还是从终端用
react-native run-ios
运行应用,都会出现。我查看了已有的答案,但没有找到任何能指引我正确方向的答案:
React-Native: Module AppRegistry is not a registered callable module
React Native: Module AppRegistry is not a registered callable module (calling runApplication)
module appregistry is not a registered callable module (calling runApplication) Module AppRegistry is not a registered callable module and Cant find variable: Constants
React Native Module AppRegistry is not a registered callable module
Module AppRegistry is not a registered callable module only in Release configuration 我卡在这里,不知道该往哪里去。