Professional-React-and-Next.js-Course icon indicating copy to clipboard operation
Professional-React-and-Next.js-Course copied to clipboard

ISSUE: Total Pages Calculation Fix for project RMTDEV

Open Dev-Dipesh opened this issue 10 months ago • 1 comments

Project: rmtdev Video Number: 158 Video Title: Finish Pagination (Derived State)

ISSUE: In the video, we're calculating the total pages without using Math.ceil().

FIX: Math.ceil is important here because we want to round up to the nearest whole number. For example, if we have 15 jobs and we want to display 7 jobs per page, we need 3 pages.

15 / 7 = 2.14 // Simple division will set total pages to 2, which will lead to missing the last job

Math.ceil(2.14) = 3 // We need 3 pages to show all 15 jobs

Dev-Dipesh avatar Apr 12 '24 17:04 Dev-Dipesh