1
我在OS X上使用React Native,並使用Deco IDE進行編碼。React Native Project中的超級表達錯誤
我在模擬器上出現Super expression must either be a null or a function, not undefined
錯誤,保存在我的項目中。
我的主要問題似乎來自以下在線教程,似乎有一種不同於現在使用的語法。不幸的是,網上的人沒有列出他們的版本。例如,他們似乎正在丟掉大量的逗號,而我的文件卻要求它。
而這裏的只有兩個文件,我編輯的代碼的截圖...
index.ios.js:
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import ViewContainer from './app/components/ViewContainer';
class Project extends Component {
render() {
return (
<ViewContainer>
<Text>{'Hello from inside ViewContainer'}</Text>
</ViewContainer>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#00a0f0',
},
});
AppRegistry.registerComponent('Project',() => Project);
ViewContainer .js文件:
import { Component, View } from 'react-native';
class ViewContainer extends Component {
render() {
return (
<View style={styles.viewContainer}>
{this.props.children}
</View>
);
}
}
const styles = React.Stylesheet.create({
viewContainer: {
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'stretch',
},
});
module.exports = ViewContainer;
你救了我的命。在我正在觀看的內容和我實際上在做的事情之間似乎存在語法差異。您是否瞭解有關React Native的最新教程? – bmoneruxui