I'm in the learning process of React Native and working on filtering through a JSON feed. I am able to filter down to a group of data, but I am looking to filter further within that group. At "filteredItem" I am able to get the example below.
{"$id":"3","num":256,"event":"1234","description":"example description","startdate":"2018","enddate":"2019"}
If I wanted to filter down to the event number similar to how I am displaying the whole group of info how would I do that?
componentDidMount() {
return fetch('myurl')
.then((response) => response.json())
.then((responseJson) => {
this.setState({
isLoading: false,
filteredItem: responseJson.filter(item => item.$id == 3),
}, function () {
});
})
.catch((error) => {
console.error(error);
});
}
render() {
if (this.state.isLoading) {
return (
<View style={{ flex: 1, padding: 20 }}>
<ActivityIndicator />
</View>
)
}
return (
<View>
<Text>
{JSON.stringify(this.state.filteredItem, null, 2)}
</Text>
</View>)
}
}
let data = {"$id":"3","num":256,"event":"1234","description":"example description","startdate":"2018","enddate":"2019"}, thendata.eventwill give you1234is this is what you looking?this.state.filteredItem?<Text>{this.state.filteredItem}</Text>