Skip to content

Solution react_redux-list-of-posts#1104

Open
RafaelGratton wants to merge 1 commit intomate-academy:masterfrom
RafaelGratton:develop
Open

Solution react_redux-list-of-posts#1104
RafaelGratton wants to merge 1 commit intomate-academy:masterfrom
RafaelGratton:develop

Conversation

@RafaelGratton
Copy link

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts and src/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

  1. Rate AI review example

Comment on lines +57 to +87
// 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);
// };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants