Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
You set an initial initial state like this:
And then you try to call the filter array method on it when the state is an object.
Fix the reducer like this:
const reducer = (state = { tweets: tweets.data }, action) => {
switch (action.type) {
case 'DELETE': {
return {
...state,
tweets: state.tweets.filter(value => value.id !== action.id),
};
}
default:
return state;
}
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question