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

255
Views
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 answers
Answer question

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 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!