Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build performant React Native and Expo apps with best practices for lists, animations, and navigation
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/ui-scrollview-content-inset.md
1---2title: Use contentInset for Dynamic ScrollView Spacing3impact: LOW4impactDescription: smoother updates, no layout recalculation5tags: scrollview, layout, contentInset, performance6---78## Use contentInset for Dynamic ScrollView Spacing910When adding space to the top or bottom of a ScrollView that may change11(keyboard, toolbars, dynamic content), use `contentInset` instead of padding.12Changing `contentInset` doesn't trigger layout recalculation—it adjusts the13scroll area without re-rendering content.1415**Incorrect (padding causes layout recalculation):**1617```tsx18function Feed({ bottomOffset }: { bottomOffset: number }) {19return (20<ScrollView contentContainerStyle={{ paddingBottom: bottomOffset }}>21{children}22</ScrollView>23)24}25// Changing bottomOffset triggers full layout recalculation26```2728**Correct (contentInset for dynamic spacing):**2930```tsx31function Feed({ bottomOffset }: { bottomOffset: number }) {32return (33<ScrollView34contentInset={{ bottom: bottomOffset }}35scrollIndicatorInsets={{ bottom: bottomOffset }}36>37{children}38</ScrollView>39)40}41// Changing bottomOffset only adjusts scroll bounds42```4344Use `scrollIndicatorInsets` alongside `contentInset` to keep the scroll45indicator aligned. For static spacing that never changes, padding is fine.46