I have few categories pages for which I am not able to generate static pages with all the data.
I have tried to cache the result from prisma
const getProducts = cache(async ({color, theme, orientation, productCategory, limit}:{productCategory: ProductCategory, color: ProductColor,theme?: Theme, orientation: DesignOrientation, limit: number }) => {
return await ServerActionFetchProductsForProductCategory({
color,
theme,
orientation,
productCategory,
limit,
page: 1,
});
});
I am also generating static pages during build. Which is working correctly. i.e. all categories pages are bring build.
export async function generateStaticParams(){
return Object.values(Theme).map((theme) => {
return {
themeSlug: ThemeUtils.getThemeAttributes(theme).slug,
};
});
}
But when I load the page, it send the category page with loading state and not the page with data from prisma. It loads the data afterwards.
My page:
export default async function page({
searchParams,
params,
}: {
searchParams: { [key: string]: string | string[] | undefined };
params: params;
}) {
const limit = 10;
const seoComponent = new SeoCategoryPageComponent();
const color = searchParams.color as ProductColor;
const orientation = searchParams.orientation as DesignOrientation;
const theme = ThemeUtils.getThemeAttributesBySlug(params.themeSlug).theme;
const page =
(searchParams.page as string) == '' ? 0 : (searchParams.page as string);
const { products } = await getProducts({
color,
theme,
orientation,
productCategory,
limit,
});
return (
<>
<ProductCategoryList
initialProducts={products}
header={
ProductCategoryUtils.getProductCategoryAttributes(productCategory)
.title
}
theme={theme}
limit={limit}
searchParamsColor={color}
searchParamsOrientation={orientation}
searchParamsTheme={theme}
breadcrumbs={getBreadcrumbs({
productCategory,
})}
seoDescription={getSeoData(productCategory).general}
productCategory={productCategory}
/>
</>
);
}
If I remove await keyword from the category page, then ISR is correctly built and loading screen is not displayed but if I keep the await keyword then ISR although gets generated during build but loading state is present in the file (instead of data) and it get all the record afterwards.