Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

256
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda