0
我創建一個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設備,它會拋出「超級表達式必須爲空或函數,而不是未定義的」錯誤。該錯誤導致SimpleButton類聲明代碼行('導出默認類SimpleButton擴展React.Component'。
我目前使用的是最新版本的React Native,我搜索了一些解決方案,但沒有成功。請幫助我!
。
應該由我添加的方式 –
實現這兩個文件中的此修復程序「進口自陣營‘反應’; 「現在已經有效了,非常感謝! –