Solution react_redux-list-of-posts#1104
Solution react_redux-list-of-posts#1104RafaelGratton wants to merge 1 commit intomate-academy:masterfrom
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on refactoring the application to use Redux Toolkit! Your implementation successfully meets all the requirements, with well-structured slices and proper integration into the components. I am approving your solution.
For future improvements, I have a couple of minor suggestions to make the code even cleaner:
- In
src/components/PostDetails.tsx, consider removing the large blocks of commented-out code to improve readability. - In
src/features/commentsSlice.tsandsrc/features/usersSlice.ts, the empty exports (export const {} = slice.actions;) are redundant and can be safely removed.
These points don't block the approval. Keep up the great work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| // const addComment = async ({ name, email, body }: CommentData) => { | ||
| // try { | ||
| // const newComment = await commentsApi.createComment({ | ||
| // name, | ||
| // email, | ||
| // body, | ||
| // postId: post.id, | ||
| // }); | ||
|
|
||
| // setComments(currentComments => [...currentComments, newComment]); | ||
|
|
||
| // // setComments([...comments, newComment]); | ||
| // // works wrong if we wrap `addComment` with `useCallback` | ||
| // // because it takes the `comments` cached during the first render | ||
| // // not the actual ones | ||
| // } catch (error) { | ||
| // // we show an error message in case of any error | ||
| // setError(true); | ||
| // } | ||
| // }; | ||
|
|
||
| // const deleteComment = async (commentId: number) => { | ||
| // // we delete the comment immediately so as | ||
| // // not to make the user wait long for the actual deletion | ||
| // // eslint-disable-next-line max-len | ||
| // setComments(currentComments => | ||
| // currentComments.filter(comment => comment.id !== commentId), | ||
| // ); | ||
|
|
||
| // await commentsApi.deleteComment(commentId); | ||
| // }; |
There was a problem hiding this comment.
These large blocks of commented-out code from a previous implementation should be removed. It's a good practice to clean up dead code to improve the readability and maintainability of the component.
|
|
||
| export default commentsSlice.reducer; | ||
|
|
||
| export const {} = commentsSlice.actions; |
There was a problem hiding this comment.
This line exports an empty object from commentsSlice.actions. Since there are no regular reducers defined in this slice, commentsSlice.actions is an empty object, making this export redundant. You can safely remove this line.
| }, | ||
| }); | ||
|
|
||
| export const {} = usersSlice.actions; |
There was a problem hiding this comment.
This line exports an empty object from usersSlice.actions. Since there are no regular reducers defined in this slice, usersSlice.actions is an empty object, making this export redundant. You can safely remove this line.
DEMO LINK