getStaticProps returns undefined props
Unanswered
American black bear posted this in #help-forum
American black bearOP
Hey! I have an issue trying to retrieve information with a database we are trying to configure with Prisma and Planetscale, for some reason I'm not successful when trying to handle StaticProps.
export default function Categories({ categories }: CategoriesProps) {
console.log(categories)
return (
<main className='main-class pb-20'>,
<nav className="navbar-style">
<div>
<ul className='navbar-container'>
<li>
<Link href="/about" className='hover:underline'>Escribir reseña</Link>
</li>
</ul>
</div>
</nav>
<div className="body-container">
<h1 className='text-2xl header'>
Todos los programas en un solo lugar
</h1>
<ul >
<li>
<Link href="/" className='hover:underline'>Software CRM</Link>
</li>
</ul>
</div>
</main>
)
}
export async function getStaticProps() {
const categories = { id : "Server functions" }
return {
props: {
categories,
},
};
}7 Replies
@American black bear Hey! I have an issue trying to retrieve information with a database we are trying to configure with Prisma and Planetscale, for some reason I'm not successful when trying to handle StaticProps.
export default function Categories({ categories }: CategoriesProps) {
console.log(categories)
return (
<main className='main-class pb-20'>,
<nav className="navbar-style">
<div>
<ul className='navbar-container'>
<li>
<Link href="/about" className='hover:underline'>Escribir reseña</Link>
</li>
</ul>
</div>
</nav>
<div className="body-container">
<h1 className='text-2xl header'>
Todos los programas en un solo lugar
</h1>
<ul >
<li>
<Link href="/" className='hover:underline'>Software CRM</Link>
</li>
</ul>
</div>
</main>
)
}
export async function getStaticProps() {
const categories = { id : "Server functions" }
return {
props: {
categories,
},
};
}
app router? then you dont have
pages router? you only have
getStaticPropspages router? you only have
getStaticProps for page files, normal component files don't have itAmerican black bearOP
hey
ive just fixed that
actually created a funciton getData() and used the same prisma function to define my const
and then pass it to my function
thank you!
glad you fixed it, have fun coding!