[英]TypeError: Super expression must either be null or a function _inherits in react native
In react-native.I will create a simple app and also a web app.在 react-native.I 中,我将创建一个简单的应用程序和一个 Web 应用程序。 React-native application output the error show in image. React-native 应用程序输出错误显示在图像中。
Super expression must either be null or a function, not undefined超级表达式必须为 null 或函数,不能为 undefined
My code is:我的代码是:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
class App extends React.Component() {
render(){
return (
<View style={styles.container}>
<Text>Hello World</Text>
</View>
);
}
}
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Try removing the parenthesis on the class definition.尝试删除类定义上的括号。
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
class App extends React.Component {
render(){
return (
<View style={styles.container}>
<Text>Hello World</Text>
</View>
);
}
}
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.