i m making a simple landing page with next js, typescript and firebase. i take the products from the firestore db and load them into my state (React context). The problem is that i want to use ISR to access to a product for example: "localhost:3000/product/[slug].tsx" get this error
法典:
interface Props {
slug:Products
}
const ProductPage: NextPage<Props> = ({ slug }) => {
const { products } = useContext(DbContext)
const product = products.filter(product => product.slug === `${slug}`)
return (
<MainLayout title={``} pageDescription={ } imageFullUrl={ }>
// product tsx
</MainLayout>
)
}
export const getStaticPaths: GetStaticPaths = async (ctx) => {
const { products } = useContext(DbContext)
const slugs = products.map(product => product.slug)
return {
paths: slugs.map((slug) => ({
params: { slug }
})),
fallback: "blocking"
}
}
export const getStaticProps: GetStaticProps = async ({ params }) => {
const { slug } = params as { slug: string }
if (!slug) {
return {
redirect: {
destination: "/",
permanent: false
}
}
}
return {
props: {
slug
},
revalidate:86400
}
}
export default ProductPage
nk!