2016-09-06 35 views
1

我在OS X上使用React Native,並使用Deco IDE進行編碼。React Native Project中的超級表達錯誤

我在模擬器上出現Super expression must either be a null or a function, not undefined錯誤,保存在我的項目中。

我的主要問題似乎來自以下在線教程,似乎有一種不同於現在使用的語法。不幸的是,網上的人沒有列出他們的版本。例如,他們似乎正在丟掉大量的逗號,而我的文件卻要求它。

這裏的錯誤 error on project save

而這裏的只有兩個文件,我編輯的代碼的截圖...

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; 

回答

2

ViewContainer組件更新它是這樣的:

import React, { Component } from 'react'; 
import { View, StyleSheet } from 'react-native'; 

class ViewContainer extends Component { 
    render() { 
    return (
     <View style={styles.viewContainer}> 
     {this.props.children} 
     </View> 
    ); 
    } 
} 

const styles = StyleSheet.create({ 

    viewContainer: { 
    flex: 1, 
    flexDirection: 'column', 
    justifyContent: 'flex-start', 
    alignItems: 'stretch', 
    }, 

}); 

module.exports = ViewContainer; 

1導入反應,並導入組件反應沒有反應過來本地

2 - 有拼寫錯誤樣式表應該是是UpperCase,並從反應本機導入它

+0

你救了我的命。在我正在觀看的內容和我實際上在做的事情之間似乎存在語法差異。您是否瞭解有關React Native的最新教程? – bmoneruxui

相關問題