Skip to content

feat(layout): provide column index using useColumnIndex hook - #2518

Draft
mdjastrzebski wants to merge 1 commit into
Shopify:mainfrom
mdjastrzebski:feat/use-column-index
Draft

mdjastrzebski wants to merge 1 commit into
Shopify:mainfrom
mdjastrzebski:feat/use-column-index

Conversation

@mdjastrzebski

@mdjastrzebski mdjastrzebski commented Oct 2, 2026 •

Copy link
Copy Markdown

Description

Resolves #1838

Adds useColumnIndex() to @shopify/flash-list. It returns the zero-based column of an item in grid and masonry layouts. In masonry, index % numColumns gives the wrong column due to item arrangement optimisation.

Investigated adding this a param to renderItem but that resulted in additional renderItem calls, when just the columnIndex changed. In sample check, with 2 column masonry layout it increased the renderItem calls from 14 => 22.

Reviewers’ hat-rack 🎩

  • yarn test --forceExit: new tests cover linear, grid (spans, numColumns changes) and masonry (column changes after measurement without re-running renderItem)
  • RTL: column 0 should be the rightmost column

Screenshots or videos (if needed)

N/A: no visual changes.

@mdjastrzebski

Copy link
Copy Markdown
Author

I have signed the CLA!

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to get columnIndex when use FlashList masonry numColumns={2} in V2?

1 participant