Skip to content

Commit

Permalink
render collections only if !== undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityblast committed Apr 24, 2024
1 parent d194034 commit 98d8f8f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,10 @@ const collectionGridLayout = [0, 5, 6, 11];

const DISPLAY_COUNT = 12;

export function CollectionsGrid({
data,
}: {
data: CommunityCollection[] | undefined;
}) {
export function CollectionsGrid({ data }: { data: CommunityCollection[] }) {
// Shuffle the collections
const shuffled = useMemo(() => shuffle(data), [data]);

if (!data) {
return null;
}

return (
<div className="md:grid space-y-4 md:space-y-0 md:grid-cols-4 gap-6">
{shuffled?.slice(0, DISPLAY_COUNT).map((collection, i) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ const LandingPage = () => {
<LandingHero />

<LandingSection title="Community collections">
<CollectionsGrid data={collections.data} />
{collections.data !== undefined && (
<CollectionsGrid data={collections.data} />
)}
</LandingSection>

<LandingSection
Expand Down

0 comments on commit 98d8f8f

Please sign in to comment.