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

116
Views
How to list out NextJS router param array

I have a NextJS catch all route which pulls in

import { useRouter} from 'next/router'

And retrieves all the parameters:

const { params = [] } = router.query

If I log the params value I see all the URL path elements in the console.

I would like to repeat out all the params values in an unordered list:

return <ul>
  {params.map((param) => {
    <li>{param}</li>
  })}
</ul>

But this outputs nothing. There are no elements displayed.

How can I get this to display the list?

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

0

With curly braces you will have to write the return keyword too.

return <ul>
  {params.map((param) => {
    return (<li>{param}</li>);
  })}
</ul>

This is how arrow functions work in JS.

With the current code, there is no return statement basically. So by default undefined is returned and nothing is rendered :

return <ul>
  {params.map((param) => {
    <li>{param}</li>
    //No return statement  
})}
</ul>

For short : You can remove the curly braces.

return <ul>
  {params.map((param) => <li>{param}</li>)}
</ul>
about 4 years ago · Juan Pablo Isaza Report

0

I think you have a problem with your .map function. Try doing this instead:

return params.map((param) => param);

This will just print your params together in a single line. You can improvise the format in which you would actually want it.

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!