From 81ce86f0929098eebf3972ddaa6abf7491f162c6 Mon Sep 17 00:00:00 2001 From: gitdagray Date: Fri, 24 Jun 2022 12:26:16 -0500 Subject: [PATCH] Added new post id increment to addNewPost payload --- 04_lesson/src/features/posts/postsSlice.js | 1 + 1 file changed, 1 insertion(+) diff --git a/04_lesson/src/features/posts/postsSlice.js b/04_lesson/src/features/posts/postsSlice.js index 354f55c..7dbe13b 100644 --- a/04_lesson/src/features/posts/postsSlice.js +++ b/04_lesson/src/features/posts/postsSlice.js @@ -106,6 +106,7 @@ const postsSlice = createSlice({ state.error = action.error.message }) .addCase(addNewPost.fulfilled, (state, action) => { + action.payload.id = state.posts[state.posts.length - 1].id + 1; action.payload.userId = Number(action.payload.userId) action.payload.date = new Date().toISOString(); action.payload.reactions = {