Lodash installation issue in Pagination section - please assist

Hello,
Good Day,

I’m at the pagination section and struck at “lodash” part. I’ve attached both my pagination code, and vulnerabilities displayed when I installed the lodash@4.17.10.
After repeating the same steps, still I see only 1-page number in my vidly project.
I doubt some version or compatibility issues in lodash cause this issue.
It`d be




more helpful if anyone could assist on this issue ASAP since I couldn’t move to the next session soon.

Thanks,
Raj

That version of lodash is 4 years old. Unless there is some specific reason that version is needed, you should probably just install the latest version (which is still 2 years old - better, but not great; the package on GitHub has no commits since 2021). That is… if you actually need lodash at all.

There are questions about if lodash is still necessary now that JavaScript actually supports many of the functions that lodash gave you - Lodash in 2022: necessary or obsolete? – Nico Zerpa, Your JavaScript Friend. I believe a rough equivalent for the range function you are using would be [...Array(pagesCount).keys()] (though you would have to change the usage of page to be page+1 since the range call started at 1 instead of 0).

const pages = [...Array(pagesCount).keys()];

return <nav>
    <ul className="pagination">
      {pages.map(page => (
        <li className="page-item">
          <a className="page-link">{page+1}</a>
        </li>
      </ul>
    </nav>;
3 Likes

Hi,
I would have said he needs lodash in the context of the course but if JS covers many of those features that’s both a good news and good read.
Thanks.

still I see only 1-page number in my vidly project:: solution 

do a console log with pagesCount if return decimal number ex. 0.97, then convert it to number with Math.ceil and return with a condition ex. if (pagesCount === 1) return null;