In React I have some filters in a state:
this.state {
filters: [countries: {parameterName: 'country', value: 'England'},
{parameterName: 'country', value: 'Greenland'}]
}
In an onClick-Handler function I receive one of these objects:
removeFilter(filter) {
console.log('remove->', filter);
// outputs: {value: 'England', parameterName: 'country'}
}
Is there a way to remove that object from my state using setState? I currently try using 'find' to get the object inside the state itself but I'm not sure how to remove it:
let found ? this.state.filters[filter.parameterName].find(element => element.value === filter.value))