【发布时间】:2017-12-30 20:05:03
【问题描述】:
我在 javascript 文件中创建了一个名为 SimpleButton 的自定义组件:
import React, {
Text,
View
} from 'react-native';
export default class SimpleButton extends React.Component{
render(){
return (
<View>
<Text>Simple Button</Text>
</View>
);
}
}
然后我将它导入到索引 javascript 文件中:
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, {
AppRegistry,
StyleSheet,
View
} from 'react-native';
import SimpleButton from './App/Components/SimpleButton';
class ReactNotes extends React.Component {
render() {
return (
<View style={styles.container}>
<SimpleButton/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
}
});
AppRegistry.registerComponent('ReactNotes', () => ReactNotes);
最后,在 Android 设备上运行它,它会抛出“Super expression must be null or a function, not undefined”错误。错误导致SimpleButton类声明代码行('export default class SimpleButton extends React.Component'.
我目前使用最新版本的 React Native。我已经搜索了一些解决方案但不起作用。请帮帮我!
【问题讨论】:
标签: react-native