Skip to content

Commit

Permalink
shared var
Browse files Browse the repository at this point in the history
  • Loading branch information
nlkluth committed Dec 5, 2023
1 parent 98f0adb commit 6938414
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/nextjs/app/migration/products/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ interface PageProps {
const ProductPage: NextPage<PageProps> = ({ data }) => {
const query = useSearchParams();
const product = data?.product;
const variant = query?.get("variant");

const selectedVariant =
(product?.variants || []).find((v) => v?.slug && v.slug === query?.get("variant")) || product?.variants?.[0];
(product?.variants || []).find((v) => v?.slug && v.slug === variant) || product?.variants?.[0];

return (
<React.Fragment>
Expand All @@ -39,7 +40,7 @@ const ProductPage: NextPage<PageProps> = ({ data }) => {
</div>
<div className="flex flex-col gap-6 py-6">
<AnimatePresence initial={false} mode="wait">
<React.Fragment key={`${query?.get("slug")}:${query?.get("variant")}`}>
<React.Fragment key={`${query?.get("slug")}:${variant}`}>
<FadeInOut>
<PageBody product={product} variant={selectedVariant} />
</FadeInOut>
Expand Down

0 comments on commit 6938414

Please sign in to comment.