run on android emulator but undefined is not an object (evaluating 'thia.state.dataSource') pls help me, what is wrong ? could you help me undefined is not an object (evaluating 'thia.state.dataSource') undefined is not an object (evaluating 'thia.state.dataSource') undefined is not an object (evaluating 'thia.state.dataSource') undefined is not an object (evaluating 'thia.state.dataSource')
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Button,
ListView,
TouchableHighlight,
Alert,
} from 'react-native';
export default class deneme1 extends Component {
constructor() {
super();
var ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
this.state = {
dataSource: ds.cloneWithRows([])
};
}
componentDidMount() {
var tit = [];
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
var response = JSON.parse(xmlhttp.responseText);
for (var i = 0; i < response.movies.length; i++) {
tit.push(response.movies[i].title);
}
Alert.alert(tit.toString());
this.setState({
dataSource: this.state.dataSource.cloneWithRows(tit)
})
}
};
xmlhttp.open("GET", 'https://facebook.github.io/react-native/movies.json', true);
xmlhttp.send();
}
render() {
return (
<View style={styles.container}>
<ListView
enableEmptySections={true}
dataSource={this.state.dataSource}
renderRow={this.renderRow} />
</View>
);
}
renderRow(dataRow) {
<TouchableHighlight>
<View>
<Text>
{dataRow}
</Text>
</View>
</TouchableHighlight>
}
}
const styles = StyleSheet.create({
on: {
width: 100,
height: 100,
backgroundColor: 'yellow',
},
off: {
width: 100,
height: 100,
backgroundColor: 'black',
},
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('deneme1', () => deneme1);