2016-11-12 75 views
0

幫助,我嘗試編碼一個應用程序,我似乎無法通過此錯誤。REACT-NATIVE SyntaxError未終止的JSX內容(57:41)

var React = require('react-native'); 

var { 
    View, 
    Text, 
    StyleSheet 
} = React; 

var styles = StyleSheet.create({ 
    mainContainer: { 
    flex: 1, 
    padding: 30, 
    marginTop: 65, 
    flexDirection: 'column', 
    justifyContent: 'center', 
    backgroundColor: '#48BBEC' 
    }, 
    title: { 
    marginBottom: 20, 
    fontSize: 25, 
    textAlign: 'center', 
    color: '#fff' 
    }, 
    searchInput: { 
    height: 50, 
    padding: 4, 
    marginRight: 5, 
    fontSize: 23, 
    borderWidth: 1, 
    borderColor: 'white', 
    borderRadius: 8, 
    color: 'white' 
    }, 
    buttonText: { 
    fontSize: 18, 
    color: '#111', 
    alignSelf: 'center' 
    }, 
    button: { 
    height: 45, 
    flexDirection: 'row', 
    backgroundColor: 'white', 
    borderColor: 'white', 
    borderWidth: 1, 
    borderRadius: 8, 
    marginBottom: 10, 
    marginTop: 10, 
    alignSelf: 'stretch', 
    justifyContent: 'center' 
    }, 
}); 

class Main extends React.Component{ 
    render(){ 
    return (
     <View style={styles.mainContainer}> 
     <Text> Testing the Router </Text> 
     </View> 
    ) 
    } 
}; 

module.exports = Main; 

我認爲問題就出在這一塊

class Main extends React.Component{ 
    render(){ 
    return (
     <View style={styles.mainContainer}> 
     <Text> Testing the Router </Text> 
     </View> 
    ) 
    } 
}; 

有錯誤消息:SyntaxError錯誤/Users/tevinrivera/Rondeh/App/Components/Main.js:未終止的JSX內容(57:41 )

回答

0

你的進口是錯誤的。你需要從'react'和其他東西,比如View,Stylesheet等'react-native'中導入React。

喜歡的東西會工作:

import React from 'react'; 

import { 
    View, 
    Text, 
    StyleSheet 
} from 'react-native'; 
0

一切看起來不錯。嘗試改變這種代碼

var React = require('react-native'); 

var { 
    View, 
    Text, 
    StyleSheet 
} = React; 

這個

const React = require('React'); 
const ReactNative = require('react-native'); 
const{ 
    StyleSheet, 
    View, 
    Text 
} = ReactNative; 
+0

仍然沒有奏效,所以輸了... –

+0

所以@TevinRivera我複製你的代碼到我的項目之一,所有我需要做的就是改變進口有效。檢查我的新的更新的答案希望它有幫助。 –