This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 57).
LazyHStack
A SwiftUI LazyHStack component for lazy horizontal layouts.
Expo UI LazyHStack matches the official SwiftUI LazyHStack API and arranges its children horizontally.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
Basic lazy horizontal stack
Put LazyHStack inside a ScrollView with axes="horizontal". Each child of LazyHStack is one item. Use the spacing and alignment props to space and align the items.
Large lists
Use LazyHStack.ForEach to render items from an array. Pass the items as data, a unique key for each item with keyExtractor, and a children function that returns the view for an item. LazyHStack.ForEach renders only the items near the visible area and reuses them while you scroll.
Follow these rules when you render items:
- Define the
childrenfunction outside the component, or wrap it inuseCallback. Otherwise, the items near the visible area render again each time the component renders. - A reused view keeps the local state (
useState) of the item it showed before. Reset the state when the item changes, or keep the state outside the view. - An item that is not ready yet shows an empty placeholder. Set
estimatedItemSizeclose to the width of your items, in points. - Use
overscanCountto prepare more items before and after the visible items. - To update the items, pass a new
dataarray. Do not change the array in place. - Set
recycling={false}to render every item up front.
API
import { LazyHStack } from '@expo/ui/swift-ui';
No API data file found, sorry!