Skip to content

Commit

Permalink
Merge pull request #15054 from artsy/DIA-1050-homepage-hero-units-con…
Browse files Browse the repository at this point in the history
…tains-a-duplicate-entry-when-logged-in

fix(home): ensures we count cells correctly when logged in
  • Loading branch information
dzucconi authored Jan 7, 2025
2 parents dfdda0e + d4d1c2a commit 8385611
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/Components/HeroCarousel/HeroCarousel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { Media } from "Utils/Responsive"
import type { FC, ReactNode } from "react"
import {
Children,
type FC,
type ReactNode,
isValidElement,
useMemo,
} from "react"
import { HeroCarouselLarge } from "./HeroCarouselLarge"
import { HeroCarouselSmall } from "./HeroCarouselSmall"

Expand All @@ -17,14 +23,19 @@ export const HeroCarousel: FC<React.PropsWithChildren<HeroCarouselProps>> = ({
progressbarVariant,
onChange,
}) => {
const cells = useMemo(
() => Children.toArray(children).filter(isValidElement),
[children],
)

return (
<>
<Media at="xs">
<HeroCarouselSmall
onChange={onChange}
progressbarVariant={progressbarVariant}
>
{children}
{cells}
</HeroCarouselSmall>
</Media>

Expand All @@ -34,7 +45,7 @@ export const HeroCarousel: FC<React.PropsWithChildren<HeroCarouselProps>> = ({
fullBleed={fullBleed}
progressbarVariant={progressbarVariant}
>
{children}
{cells}
</HeroCarouselLarge>
</Media>
</>
Expand Down

0 comments on commit 8385611

Please sign in to comment.