Despite of numerous thread on the subject I didn't manage to remove an item of a string based Array using Array.filter method. Here is the filter method in a context of a mutation of a Vuex store.
UPDATE_FILTERS_GEOLOGIES: (state, payload) => {
if (state.filters.geologies.some(elem => elem === payload)) {
state.filters.geologies.filter(elem => !elem.includes(payload))
} else {
state.filters.geologies.push(payload);
}
}
The filter method is call but the item is not removed. I ended up using Array.splice method:
let position = state.filters.geologies.indexOf(payload);
state.filters.geologies.splice(position, 1)
Could you tell me what I'm doing wrong?
filterdoes not mutate the original array.state.filters.geologies = state.filters.geologies.filter(elem => !elem.includes(payload))state.filters.geologiesbecomes not reactive.