Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
How to conditionally show list items in React based on screen size

I am trying to create a navigation with a 'more' menu. It seems to be a fairly simple concept.. CBS Sports is an example of it (https://www.cbssports.com/)

Basically show as many links as possible, and push the rest to the dropdown.

Is there a correct approach to implementing this in react? Basically change the count of visible items based on the size of the screen?

I've been trying to find an example of an implementation but am not sure how to find it.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Changing the count of visible items based on the size of the screen for me is a good idea. You can create variable which give you number of visible items. Later you can map after filtered items from array which contains all items. For example

arr.filter((_,i)=> i < number).map(item=> (<li>{item}</li>))

and for item which go to dropdown

arr.filter((_,i)=> i >= number).map(item=> (<li>{item}</li>))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!