106
rated 0 times
[
107]
[
1]
/ answers: 1 / hits: 16354
/ 8 Years ago, wed, august 3, 2016, 12:00:00
I am trying to create empty array in react-native using es6. But while accessing it I get an error data not defined.
Here is the code snippet which I am using to initialise the array.
constructor() {
super();
this.state = {
search: "",
data: []
}
}
Here is the code through which I am trying to populate the array and at the same time logging it
.then((responseData) => {
this.setState({
data: responseData.hits.hits.map(function(search){
return{
name: search._source.service_name
}
})
})
console.log(data);
I think so there is a problem in initialisation of array can anybody rectify it?
More From » arrays