Reputation: 198
I've got a filter method that check if result
doesn't contain value from this.state.filter
it should be delete.
My problem is method doesn't remove wrong result
. It makes null
filter(){
const {fetchData} = this.state;
return fetchData.map((result, index) => (
(result[3] == this.state.filter) ?
result : null //there is my problem
))
}
screens from console.log
Upvotes: 0
Views: 62
Reputation: 9542
Instead of map
you must be using Array.prototype.filter
to remove elements from array:
filter() {
const { fetchData } = this.state;
return fetchData.filter( (subarray) => (
subarray[3] === this.state.filter
));
}
Upvotes: 4