Skip to content

Comments

solution#1438

Open
aakash1sadhu wants to merge 3 commits intomate-academy:masterfrom
aakash1sadhu:develop
Open

solution#1438
aakash1sadhu wants to merge 3 commits intomate-academy:masterfrom
aakash1sadhu:develop

Conversation

@aakash1sadhu
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

Great work on the core pagination logic! The state management and calculations are implemented well. However, I'm requesting one small but important fix before approving. The navigation links in your Pagination component are missing their required symbols, which is a specific requirement from the task description.

  • In src/components/Pagination/Pagination.tsx, please add the « symbol to the 'previous' link and the » symbol to the 'next' link.

As a suggestion for improvement, consider implementing the optional requirement to manage state in the URL with React Router. It's a great pattern to practice. Also, moving the arrayNumOfPages helper function outside the component body would prevent it from being recreated on every render.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +10 to +11
const [perPage, setPerPage] = useState(5);
const [currentPage, setCurrentPage] = useState(1);

Choose a reason for hiding this comment

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

The task requires using React Router to manage state in the URL. Currently, perPage and currentPage are stored in local component state using useState. This state should be synchronized with the URL query parameters (e.g., ?page=...&perPage=...) so that the values are applied on page load and the URL reflects the current pagination state.

Comment on lines 19 to 27
function arrayNumOfPages(value: number) {
const pages = [];

for (let i = 1; i <= value; i++) {
pages.push(i);
}

return pages;
}

Choose a reason for hiding this comment

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

This helper function is re-created on every render because it's defined inside the component. It would be more efficient to define it outside the component body. You could also create the array more concisely, for example, with Array.from({ length: value }, (_, i) => i + 1).

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

Great work on this iteration! I am approving your solution as you've successfully addressed the previous feedback and met all the core requirements. The pagination logic is solid, and the component functions as expected.

I have one minor suggestion to improve code consistency in src/components/Pagination/Pagination.tsx. Consider using the totalPages variable for disabling the 'next' link's onClick and aria-disabled attributes, just as you do for the li element's disabled class. This is a minor point for readability and doesn't affect the functionality.

Excellent job overall!


✨ 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 +79 to +84
aria-disabled={currentPage === pages[pages.length - 1]}
onClick={event => {
event.preventDefault();
if (currentPage !== pages[pages.length - 1]) {
onPageChange(currentPage + 1);
}

Choose a reason for hiding this comment

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

Your logic for disabling the 'next' link is correct. For consistency, consider using the totalPages variable here, just as you did for the li element's disabled class on line 72. Using totalPages consistently makes the code more readable and avoids relying on the last element of the pages array.

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