2016-11-29 96 views
-1

我正在學習本教程以使React Native應用程序 - >https://firebase.googleblog.com/2016/01/the-beginners-guide-to-react-native-and_84.html和我在嘗試編譯iOS應用程序時遇到一些錯誤。SyntaxError:未終止的JSX內容

任何幫助?

screenshot of the error

這裏是我的代碼...

import React, {Component} from 'react'; 
import {ReactNative, 
AppRegistry, 
ListView, 
StyleSheet, 
ActionButton, 
Text, 
View, 
TouchableHighlight, 
AlertIOS } from 'react-native'; 
import * as firebase from 'firebase'; 
const StatusBar = require('./components/StatusBar'); 
const ActionButton = require('./components/ActionButton'); 
const ListItem = require('./components/ListItem'); 
const styles = require('./styles.js'); 

const { 

} = ReactNative; 

// Initialize Firebase 
const firebaseConfig = { 
apiKey: "******", 
authDomain: "*****", 
databaseURL: "******", 
storageBucket: "******", 
messagingSenderId: "******" 
}; 
const firebaseApp = firebase.initializeApp(firebaseConfig); 



class GroceryApp extends Component { 

constructor(props) { 
super(props); 
this.state = { 
dataSource: new ListView.DataSource({ 
    rowHasChanged: (row1, row2) => row1 !== row2, 
}) 
}; 
} 

componentDidMount() { 
this.setState({ 
    dataSource: this.state.dataSource.cloneWithRows([{ title: 'Pizza' }]) 
}) 
} 


_renderItem(item) { 
    return (
    <ListItem item={item} /> 
); 
} 

render() { 
    return (
    <View style={styles.container}> 

    <StatusBar title="Grocery List"> 

    <ListView 
    datasource={this.state.dataSource} 
    renderrow={this._renderItem.bind(this)} 
    style={styles.listview} 
    /> 

    <ActionButton title="Add" /> 

    </View> 
); 
} 

} 

AppRegistry.registerComponent('GroceryApp',() => GroceryApp); 
+0

''需要關閉,像''我 – peterp

回答

0

狀態欄需要關閉。

import React, {Component} from 'react'; 
 
import {ReactNative, 
 
AppRegistry, 
 
ListView, 
 
StyleSheet, 
 
ActionButton, 
 
Text, 
 
View, 
 
TouchableHighlight, 
 
AlertIOS } from 'react-native'; 
 
import * as firebase from 'firebase'; 
 
const StatusBar = require('./components/StatusBar'); 
 
const ActionButton = require('./components/ActionButton'); 
 
const ListItem = require('./components/ListItem'); 
 
const styles = require('./styles.js'); 
 

 
const { 
 

 
} = ReactNative; 
 

 
// Initialize Firebase 
 
const firebaseConfig = { 
 
apiKey: "******", 
 
authDomain: "*****", 
 
databaseURL: "******", 
 
storageBucket: "******", 
 
messagingSenderId: "******" 
 
}; 
 
const firebaseApp = firebase.initializeApp(firebaseConfig); 
 

 

 

 
class GroceryApp extends Component { 
 

 
constructor(props) { 
 
super(props); 
 
this.state = { 
 
dataSource: new ListView.DataSource({ 
 
    rowHasChanged: (row1, row2) => row1 !== row2, 
 
}) 
 
}; 
 
} 
 

 
componentDidMount() { 
 
this.setState({ 
 
    dataSource: this.state.dataSource.cloneWithRows([{ title: 'Pizza' }]) 
 
}) 
 
} 
 

 

 
_renderItem(item) { 
 
    return (
 
    <ListItem item={item} /> 
 
); 
 
} 
 

 
render() { 
 
    return (
 
    <View style={styles.container}> 
 

 
    <StatusBar title="Grocery List"/> 
 

 
    <ListView 
 
    datasource={this.state.dataSource} 
 
    renderrow={this._renderItem.bind(this)} 
 
    style={styles.listview} 
 
    /> 
 

 
    <ActionButton title="Add" /> 
 

 
    </View> 
 
); 
 
} 
 

 
} 
 

 
AppRegistry.registerComponent('GroceryApp',() => GroceryApp);

+0

關閉它。而另一個錯誤出現http://prntscr.com/dd6a9e – djumerko

+0

這是什麼錯誤? –

+0

未定義不是對象(評估'dataSource.rowIdentities') – djumerko

0

狀態欄不具有關閉標籤 -