Jeffallan/claude-skills / skills/react-native-expert
react-native-expert
VerifiedBuilds, optimizes, and debugs cross-platform mobile applications with React Native and Expo. Implements navigation hierarchies (tabs, stacks, drawers), configures native modules, optimizes FlatList rendering with memo and useCallback, and handles platform-specific code for iOS and Android. Use when building a React Native or Expo mobile app, setting up navigation, integrating native modules, improving scroll performance, handling SafeArea or keyboard input, or configuring Expo SDK projects.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.5 KB |
| references/expo-router.md | markdown | 4.0 KB |
| references/list-optimization.md | markdown | 4.3 KB |
| references/platform-handling.md | markdown | 3.8 KB |
| references/project-structure.md | markdown | 4.0 KB |
| references/storage-hooks.md | markdown | 4.3 KB |
references/list-optimization.md
View on GitHub# List Optimization
## Optimized FlatList
```typescript
import { FlatList, ListRenderItem } from 'react-native';
import { memo, useCallback } from 'react';
interface Item {
id: string;
title: string;
subtitle: string;
}
// Memoized list item
const ListItem = memo(function ListItem({
item,
onPress
}: {
item: Item;
onPress: (id: string) => void;
}) {
return (
<Pressable onPress={() => onPress(item.id)} style={styles.item}>
<Text style={styles.title}>{item.title}</Text>
<Text style={styles.subtitle}>{item.subtitle}</Text>
</Pressable>
);
});
function OptimizedList({ data }: { data: Item[] }) {
// Memoize callbacks
const handlePress = useCallback((id: string) => {
console.log('Selected:', id);
}, []);
const renderItem: ListRenderItem<Item> = useCallback(
({ item }) => <ListItem item={item} onPress={handlePress} />,
[handlePress]
);
const keyExtractor = useCallback((item: Item) => item.id, []);
// Fixed height for getItemLayout
const getItemLayout = useCallback(
(_: any, index: number) => ({
length: ITEM_HEIGHT,
offset: ITEM_HEIGHT * index,
index,
}),
[]
);
return (
<FlatList
data={data}
renderItem={renderItem}
keyExtractor={keyExtractor}
getItemLayout={getItemLayout}
// Performance props
removeClippedSubviews
maxToRenderPerBatch={10}
windowSize={5}
initialNumToRender={10}
updateCellsBatchingPeriod={50}
/>
);
}
const ITEM_HEIGHT = 72;
```
## SectionList
```typescript
import { SectionList } from 'react-native';
interface Section {
title: string;
data: Item[];
}
function GroupedList({ sections }: { sections: Section[] }) {
const renderSectionHeader = useCallback(
({ section }: { section: Section }) => (
<View style={styles.sectionHeader}>
<Text style={styles.sectionTitle}>{section.title}</Text>
</View>
),
[]
);
return (
<SectionList
sections={sections}
renderItem={renderItem}
renderSectionHeader={renderSectionHeader}
keyExtractor={keyExtractor}
stickySectionHeadersEnabled
/>
);
}
```
## Pull to Refresh
```typescript
function RefreshableList({ data, onRefresh }: Props) {
const [refreshing, setRefreshing] = useState(false);
const handleRefresh = useCallback(async () => {
setRefreshing(true);
await onRefresh();
setRefreshing(false);
}, [onRefresh]);
return (
<FlatList
data={data}
renderItem={renderItem}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={handleRefresh}
tintColor="#007AFF"
/>
}
/>
);
}
```
## Infinite Scroll
```typescript
function InfiniteList() {
const [data, setData] = useState<Item[]>([]);
const [loading, setLoading] = useState(false);
const [hasMore, setHasMore] = useState(true);
const loadMore = useCallback(async () => {
if (loading || !hasMore) return;
setLoading(true);
const newItems = await fetchMoreItems(data.length);
if (newItems.length === 0) {
setHasMore(false);
} else {
setData(prev => [...prev, ...newItems]);
}
setLoading(false);
}, [data.length, loading, hasMore]);
const renderFooter = useCallback(() => {
if (!loading) return null;
return <ActivityIndicator style={styles.loader} />;
}, [loading]);
return (
<FlatList
data={data}
renderItem={renderItem}
onEndReached={loadMore}
onEndReachedThreshold={0.5}
ListFooterComponent={renderFooter}
/>
);
}
```
## FlashList (Alternative)
```typescript
import { FlashList } from '@shopify/flash-list';
function FastList({ data }: { data: Item[] }) {
return (
<FlashList
data={data}
renderItem={renderItem}
estimatedItemSize={72}
keyExtractor={keyExtractor}
/>
);
}
```
## Quick Reference
| Prop | Purpose |
|------|---------|
| `removeClippedSubviews` | Unmount off-screen items |
| `maxToRenderPerBatch` | Items per render batch |
| `windowSize` | Render window multiplier |
| `initialNumToRender` | Initial items to render |
| `getItemLayout` | Skip measurement (fixed height) |
| Optimization | When |
|--------------|------|
| `memo()` | All list items |
| `useCallback` | renderItem, keyExtractor |
| `getItemLayout` | Fixed height items |
| `FlashList` | Very large lists |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |