Skip to content

BentoStreamGallery: Use toChildArray to get the length#36154

Merged
caroqliu merged 2 commits intoampproject:mainfrom
caroqliu:children-compat
Sep 24, 2021
Merged

BentoStreamGallery: Use toChildArray to get the length#36154
caroqliu merged 2 commits intoampproject:mainfrom
caroqliu:children-compat

Conversation

@caroqliu
Copy link
Copy Markdown
Contributor

Use toChildArray to get the children.length, partial for #35678

const carouselRef = useRef(null);
const [visibleCount, setVisibleCount] = useState(DEFAULT_VISIBLE_COUNT);

const length = useMemo(() => toChildArray(children), [children]);
Copy link
Copy Markdown
Contributor

@dmanek dmanek Sep 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. toChildArray(children).length right?
  2. nit: useMemo might be an overkill here. Typically its used for expensive calculations - calculating length isn't one of them 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on both accounts, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants