From 049d903a5bf60d34981c85a0b7883e912a98045d Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Sat, 29 Jul 2023 00:19:13 +0800 Subject: [PATCH 1/5] Removes unnecessary `useEffect`'s on search sorts (#1124) --- components/layout/search/filter/item.tsx | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/components/layout/search/filter/item.tsx b/components/layout/search/filter/item.tsx index d9298582c..38777ea48 100644 --- a/components/layout/search/filter/item.tsx +++ b/components/layout/search/filter/item.tsx @@ -5,22 +5,17 @@ import { SortFilterItem } from 'lib/constants'; import { createUrl } from 'lib/utils'; import Link from 'next/link'; import { usePathname, useSearchParams } from 'next/navigation'; -import { useEffect, useState } from 'react'; import type { ListItem, PathFilterItem } from '.'; function PathFilterItem({ item }: { item: PathFilterItem }) { const pathname = usePathname(); const searchParams = useSearchParams(); - const [active, setActive] = useState(pathname === item.path); + const active = pathname === item.path; const newParams = new URLSearchParams(searchParams.toString()); const DynamicTag = active ? 'p' : Link; newParams.delete('q'); - useEffect(() => { - setActive(pathname === item.path); - }, [pathname, item.path]); - return (
  • { - setActive(searchParams.get('sort') === item.slug); - }, [searchParams, item.slug]); - return (
  • Date: Fri, 28 Jul 2023 16:57:45 -0500 Subject: [PATCH 2/5] Adds anchor for v1 note (#1125) * Adds anchor for v1 note * Adds period --------- Co-authored-by: Lee Robinson --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c3fa3f6b5..9f1a06883 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,9 @@ A Next.js 13 and App Router-ready ecommerce template featuring: - Checkout and payments with Shopify - Automatic light/dark mode based on system settings -> Note: Looking for Next.js Commerce v1? View the [code](https://github.com/vercel/commerce/tree/v1), [demo](https://commerce-v1.vercel.store), and [release notes](https://github.com/vercel/commerce/releases/tag/v1) +

    + +> Note: Looking for Next.js Commerce v1? View the [code](https://github.com/vercel/commerce/tree/v1), [demo](https://commerce-v1.vercel.store), and [release notes](https://github.com/vercel/commerce/releases/tag/v1). ## Providers From 1449489c3c8eb66104f7bb699cbb2f4339708589 Mon Sep 17 00:00:00 2001 From: Michael Novotny Date: Fri, 28 Jul 2023 16:59:27 -0500 Subject: [PATCH 3/5] Fixes copyright spacing on medium screens (#1122) Co-authored-by: Lee Robinson --- components/layout/footer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/layout/footer.tsx b/components/layout/footer.tsx index 989f9992c..2f41606e0 100644 --- a/components/layout/footer.tsx +++ b/components/layout/footer.tsx @@ -50,7 +50,7 @@ export default async function Footer() {
    -
    +

    © {copyrightDate} {copyrightName} {copyrightName.length && !copyrightName.endsWith('.') ? '.' : ''} All rights reserved. From cd8f4c6b4c17fe7488cc8f8c3df6ce265fa9885c Mon Sep 17 00:00:00 2001 From: Lee Robinson Date: Fri, 28 Jul 2023 17:00:48 -0500 Subject: [PATCH 4/5] Fix hydration error (#1117) --------- Co-authored-by: Michael Novotny --- components/cart/add-to-cart.tsx | 21 +++-- components/product/variant-selector.tsx | 113 +++++++++--------------- 2 files changed, 56 insertions(+), 78 deletions(-) diff --git a/components/cart/add-to-cart.tsx b/components/cart/add-to-cart.tsx index 15582acc3..d737b6678 100644 --- a/components/cart/add-to-cart.tsx +++ b/components/cart/add-to-cart.tsx @@ -15,7 +15,7 @@ export function AddToCart({ variants: ProductVariant[]; availableForSale: boolean; }) { - const [selectedVariantId, setSelectedVariantId] = useState(variants[0]?.id); + const [selectedVariantId, setSelectedVariantId] = useState(undefined); const router = useRouter(); const searchParams = useSearchParams(); const [isPending, startTransition] = useTransition(); @@ -27,17 +27,24 @@ export function AddToCart({ ) ); - if (variant) { - setSelectedVariantId(variant.id); - } + setSelectedVariantId(variant?.id); }, [searchParams, variants, setSelectedVariantId]); + const title = !availableForSale + ? 'Out of stock' + : !selectedVariantId + ? 'Please select options' + : undefined; + return (