Skip to content

nickgallick/perlantir-fleet / workspace-forge/skills/expo-react-native-patterns

expo-react-native-patterns

Verified

Expo/React Native patterns for MathMind and Arena mobile — navigation, NativeWind, performance, offline-first, push notifications, App Store deployment, security.

Expo / React Native Patterns

Review Checklist

  1. expo-image used (not Image from react-native)
  2. FlatList for lists >20 items (not ScrollView)
  3. Sensitive data in expo-secure-store (not AsyncStorage)
  4. SafeAreaView or useSafeAreaInsets() on every screen
  5. Animations use react-native-reanimated (UI thread, 60fps)
  6. Push notification permission requested at appropriate time
  7. Offline state handled gracefully
  8. Deep links tested on both iOS and Android

Platform Differences from Web

WebReact Native
<div><View>
<span>, <p><Text> (text MUST be in <Text>)
<button><Pressable>
<img><Image> from expo-image
CSS classesStyleSheet.create() or NativeWind
Flexbox (row default)Flexbox (column default)
window.localStorageAsyncStorage (unencrypted) or expo-secure-store (encrypted)
Media queriesuseWindowDimensions()

Expo Router (File-Based Navigation)

app/
├── (tabs)/              # Tab navigator group
│   ├── _layout.tsx      # Tab bar configuration
│   ├── index.tsx        # Home tab
│   ├── challenges.tsx   # Challenges tab
│   └── profile.tsx      # Profile tab
├── challenge/
│   └── [id].tsx         # Dynamic route: /challenge/abc-123
├── modal.tsx            # Presented as modal (presentation: 'modal')
└── _layout.tsx          # Root layout (auth check, providers)
// Type-safe route params
import { useLocalSearchParams } from 'expo-router'
export default function ChallengeDetail() {
  const { id } = useLocalSearchParams<{ id: string }>()
  // id is typed as string
}

Performance Patterns

FlatList over ScrollView

// ❌ Renders ALL items at once (slow for >20 items)
<ScrollView>
  {items.map(item => <ItemCard key={item.id} item={item} />)}
</ScrollView>

// ✅ Virtualizes — only renders visible items
<FlatList
  data={items}
  keyExtractor={item => item.id}
  renderItem={({ item }) => <ItemCard item={item} />}
  getItemLayout={(_, index) => ({ length: 80, offset: 80 * index, index })}
  // getItemLayout enables instant scroll-to-index
/>

expo-image over Image

// ❌ No caching, no blurhash, no transitions
import { Image } from 'react-native'
<Image source={{ uri: avatarUrl }} style={{ width: 48, height: 48 }} />

// ✅ Built-in caching, blurhash placeholder, smooth transitions
import { Image } from 'expo-image'
<Image 
  source={avatarUrl}
  style={{ width: 48, height: 48 }}
  placeholder={blurhash}
  transition={200}
  contentFit="cover"
/>

Reanimated for Animations

// ❌ JS thread animation (drops frames during heavy computation)
import { Animated } from 'react-native'

// ✅ UI thread animation (smooth 60fps always)
import Animated, { useSharedValue, useAnimatedStyle, withSpring } from 'react-native-reanimated'

function AnimatedCard() {
  const scale = useSharedValue(1)
  const animatedStyle = useAnimatedStyle(() => ({
    transform: [{ scale: scale.value }]
  }))
  
  return (
    <Pressable onPressIn={() => { scale.value = withSpring(0.95) }}
               onPressOut={() => { scale.value = withSpring(1) }}>
      <Animated.View style={animatedStyle}>
        <Text>Card content</Text>
      </Animated.View>
    </Pressable>
  )
}

Security

Storage Security

// ❌ AsyncStorage is UNENCRYPTED — visible to anyone with device access
import AsyncStorage from '@react-native-async-storage/async-storage'
await AsyncStorage.setItem('auth_token', token) // INSECURE

// ✅ expo-secure-store uses iOS Keychain / Android Keystore
import * as SecureStore from 'expo-secure-store'
await SecureStore.setItemAsync('auth_token', token) // ENCRYPTED

What Goes Where

DataStorageWhy
Auth tokensexpo-secure-storeEncrypted, OS-protected
User preferencesAsyncStorageNot sensitive
Cached API dataAsyncStorageNot sensitive, needs fast access
Problem history (MathMind)expo-sqliteStructured, offline-queryable
Encryption keysexpo-secure-storeMaximum protection

Offline-First Pattern (MathMind)

// 1. Try network, fall back to cache
async function getProblems(grade: number) {
  try {
    const online = await NetInfo.fetch()
    if (online.isConnected) {
      const data = await fetchFromSupabase(grade)
      await cacheLocally(grade, data) // update cache
      return data
    }
  } catch {} // network failed
  
  return getCachedProblems(grade) // offline fallback
}

// 2. Queue mutations for sync
async function submitAnswer(answer: Answer) {
  await saveToLocalDb(answer) // always save locally first
  
  const online = await NetInfo.fetch()
  if (online.isConnected) {
    await syncToSupabase(answer)
  } else {
    await addToSyncQueue(answer) // sync when back online
  }
}

App Store Deployment

# Build for production
eas build --platform ios --profile production

# Submit to App Store
eas submit --platform ios

# OTA update (JS-only changes, no native module changes)
eas update --branch production --message "Fix scoring display"

MathMind-Specific Considerations

  • Kids Category: requires COPPA compliance, no third-party analytics, no behavioral ads
  • Age rating: educational content, no user-generated content = likely 4+
  • Login for reviewer: provide test credentials in App Store Connect

Sources

  • expo/expo documentation
  • expo/examples (navigation, auth, notifications)
  • nativewind/nativewind (Tailwind compilation)
  • React Native performance documentation

Changelog

  • 2026-03-21: Initial skill — Expo/React Native patterns
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 465kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 465kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 465kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 192kUpdated Claude CodeCodexVerifiedInstall