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

257
Visualizações
Props not passing from getStaticPaths() to getStaticProps()

I created dynamic pages from a JSON in nextJS using getStaticPaths(), it works but I'm not able to use the information inside of the JSON, I'm passing it as props to the getStaticProps(), but when I console log it, it says undefined.

This is the getStaticPaths(), getting the JSON, then creating the paths. All working.

export async function getStaticPaths() {
  const influencers = influencersData
  const paths = influencers.map((influencer) => {
    const influencerId = influencer.name.toLowerCase().replace(/ /g, '-')
    return {
      params: {
        influencerId,
      },
    }
  })
  console.log(paths)
  return {
    paths,
    fallback: false,
  }
} 

Then this is getStaticProps()

export async function getStaticProps({ params }) {
  const influencerId = params.influencerId.replace(/\-/g, '+')
  const results = influencersData.filter(
    (influencer) => influencer.name === influencerId
  )
  console.log(results)
  return {
    props: {
      influencer: results[0],
    },
  }
}

and then this is the default function I'm exporting to create the dynamic page

export default function influencerPage(influencer) {

  console.log(influencer) /// This returns undefined 

  return (
    <>
     {influencer.name}
    </>
  )

As I'm getting undefined I cannot use the information in the JSON. Am I doing something wrong?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

influencer is a prop so it should have curly brackets around it: export default function influencerPage({influencer})

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