我试图在我的物理设备上运行我的React Native应用程序,但是每次遇到此错误
TypeError: Super expression must either be null or a function
[Mon Oct 26 2020 10:37:19.635] ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Mon Oct 26 2020 10:37:19.636] ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Mon Oct 26 2020 10:37:19.637] ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
所以我尝试只渲染一个简单的文本
export default class App extends Component {
render() {
return (
<View>
<Text>Hello</Text>
</View>
);
}
}
但是仍然出现该错误,为什么?谁能告诉我发生了什么事?
我的index.js
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => App);
答案 0 :(得分:0)
尝试将Contructor添加到App组件,并在构造函数的第一行中调用super(props)