Skip to content

Commit

Permalink
Check that FeatuedCollection collection is defined (#1373)
Browse files Browse the repository at this point in the history
add changeset

check for collection before rendering it
  • Loading branch information
juanpprieto committed Sep 25, 2023
1 parent 1be1e40 commit 06da557
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/polite-vans-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/cli-hydrogen': patch
'@shopify/create-hydrogen': patch
---

Add check to render collection images when available
3 changes: 2 additions & 1 deletion templates/skeleton/app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ function FeaturedCollection({
}: {
collection: FeaturedCollectionFragment;
}) {
const image = collection.image;
if (!collection) return null;
const image = collection?.image;
return (
<Link
className="featured-collection"
Expand Down
2 changes: 1 addition & 1 deletion templates/skeleton/app/routes/collections._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function CollectionItem({
to={`/collections/${collection.handle}`}
prefetch="intent"
>
{collection.image && (
{collection?.image && (
<Image
alt={collection.image.altText || collection.title}
aspectRatio="1/1"
Expand Down

0 comments on commit 06da557

Please sign in to comment.