Skip to content

Commit

Permalink
Update contactsSlice.js
Browse files Browse the repository at this point in the history
  • Loading branch information
danretegan committed Feb 26, 2024
1 parent b227cd4 commit f570847
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/redux/slices/contactsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ const contactsSlice = createSlice({
initialState: initialState,
reducers: {
addContact: (state, action) => {
return [...state, action.payload];
state.push(action.payload);
},
deleteContact: (state, action) => {
return state.filter(contact => contact.id !== action.payload);
const contactIndex = state.findIndex(
contact => contact.id === action.payload
);
state.splice(contactIndex, 1);
},
},
});
Expand Down

0 comments on commit f570847

Please sign in to comment.