Disappearing items in Masonry layout
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.2k
- Forks
- 393
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 1
Description
Description
When using FlashList with masonry enabled and optimizeItemArrangement set to false, items can sometimes disappear during scrolling. The issue is more likely to happen where there is a difference in column heights.
Current behavior
When there is a significant discrepancy of visible items' indices, cards sometimes disappear unexpectedly while scrolling. The root cause seems to be that the layout uses binary search for calculating visible items; and because binary search expects sorted items, the algorithm fails when there is a difference in indices between columns
Video:
https://github.com/user-attachments/assets/68e9a65a-4981-4675-b705-4985e300f491
Expected behavior
Cards should not disappear or flicker as user scrolls.
Reproduction
The issue can be reproduced in fixture app.
- Disable
optimizeItemArrangementin ComplexMasonry example:
optimizeItemArrangement={false}
- Open the ComplexMasonry screen and scroll down (see video above)
Platform
- iOS
- Android
- Web (if applicable)
Environment
FlashList version: "2.2.2"
Additional context
Checklist
- I've searched existing issues and couldn't find a duplicate
- I've provided a minimal reproduction (Expo Snack preferred)
- I'm using the latest version of @shopify/flash-list
- I've included all required information above
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with fixture/react-native/src/ComplexMasonry.tsx at the optimizeItemArrangement setting, then reproduce the disappearance by opening ComplexMasonry and scrolling with it disabled. Trace the visible-item calculation described in the issue, including its binary-search assumption across columns. Done means cards no longer disappear or flicker on both iOS and Android in this reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100