Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda