One usability issue here: the active page should always be in the middle of the rendered buttons, if there are enough pages to pad it. Otherwise, well executed, even though I prefer a functional approach that only calculates which buttons with which properties to show depending on the input that is slightly more reusable and agnostic of page content.
Without providing a fully working example, instead of having a Pagination object, you merely use a pure function (same input always produces same output) to calculate the pagination that should be displayed:
constgetPagination=(currentPage,pages,showPages)=>{constpagination=[];// ...do the calculationreturnpagination;};
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
One usability issue here: the active page should always be in the middle of the rendered buttons, if there are enough pages to pad it. Otherwise, well executed, even though I prefer a functional approach that only calculates which buttons with which properties to show depending on the input that is slightly more reusable and agnostic of page content.
Hey thanks for the feedback. I didn't quite get the functional approach. Can you elaborate a bit more for my benefit ?
Without providing a fully working example, instead of having a Pagination object, you merely use a pure function (same input always produces same output) to calculate the pagination that should be displayed: