Mobile Development Skill (React Native, Expo & Kotlin)
Follow these prioritized React Native and Kotlin mobile standards (synthesized from callstackincubator/agent-skills, vercel-react-native-skills, and expo/skills).
1. Optimization Workflow (Measure → Optimize → Re-measure → Validate)
- Never apply speculative memoization or architectural changes for performance without measuring first (React DevTools Profiler, Hermes sampling profiler, or frame timelines).
- Validate every optimization against concrete metrics: FPS (60/120fps), TTI (startup time), re-render count, and bundle size.
2. Priority 1: List & Scroll Performance (CRITICAL)
- Virtualize All Dynamic Lists (
list-performance-virtualize): Never map arrays inside aScrollViewfor dynamic/long lists. UseFlashList(note: FlashList v2 no longer requiresestimatedItemSize) orFlatList. - Memoize List Items & Stabilize Callbacks (
list-performance-item-memo):- Wrap list item components in
React.memoand keep props primitive/stable. - Avoid inline style objects (
style={{ ... }}) and inline arrow callbacks insiderenderItem. - Pass
getItemTypetoFlashListfor heterogeneous feeds so native view recycling stays fast.
- Wrap list item components in
- Images in Lists (
ui-expo-image): Useexpo-image(or FastImage) with caching,recyclingKey, and explicit dimensions instead of stock<Image>.
3. Priority 2: GPU Animations & Gestures (HIGH)
- Animate Only GPU Properties (
animation-gpu-properties): Run animations on the UI thread withreact-native-reanimatedanimatingtransformandopacity—avoid animatingwidth,height,top, orpaddingon the JS thread. - Derived Animation Values (
animation-derived-value): UseuseDerivedValuefor computed worklet animations andGesture.Tap/react-native-gesture-handlerfor coordinated touch interactions.
4. Priority 3: Navigation, Safe Areas & Rendering Safety (HIGH)
- Native Navigators (
navigation-native-navigators): Prefer native stack (@react-navigation/native-stack/ Static API orexpo-router) and native bottom tabs over JS-driven navigators. - Safe Areas & Scroll Insets (
ui-safe-area-scroll):- Use
react-native-safe-area-context(useSafeAreaInsets) orcontentInsetAdjustmentBehavior="automatic"onScrollView/FlashList. - Always set explicit
flex: 1on screen root containers to prevent layout collapse.
- Use
- React Native Rendering Guardrails:
- Text inside
<Text>(rendering-text-in-text-component): Never render raw strings outside a<Text>component (causes native crash). - Avoid Falsy
&&(rendering-no-falsy-and): Never write{count && <Badge />}or{str && <View />}—ifcountis0orstris"", React Native crashes attempting to render raw text in a<View>. Always coerce to boolean ({count > 0 && <Badge />}or ternary{count ? <Badge /> : null}). - Use
Pressable(ui-pressable): PreferPressableover legacyTouchableOpacity.
- Text inside
5. Native Android / Kotlin Modules (TurboModules / Expo Modules)
- Keep native bridges thin and strongly typed in TypeScript.
- Offload all blocking I/O, database, file, and crypto work to Kotlin coroutine dispatchers (
Dispatchers.IO/Dispatchers.Default); never block the Android UI thread. - Clean up native listeners, broadcast receivers, and coroutines on lifecycle destroy/unmount.