MustafaKucukcoskun/Refine-agent-kit / shared/.agent/skills/react-native-best-practices
react-native-best-practices
VerifiedReact Native best practices for new architecture, navigation, performance, state management, and testing.
React Native Best Practices Skill
1. New Architecture (RN 0.76+)
- JSI and Bridgeless: New Architecture is enabled by default in 0.76. Instead of Bridge-based async communication, JSI (JavaScript Interface) allows JS and Native (C++) to call each other synchronously (
nativeModule.getValue()). This dramatically improves startup time and reduces frame drops. - Incompatibility Workaround (Exception Pattern): If an older package does not support New Architecture and is required, opt-out for that build only by adding
newArchEnabled=falsein Android'sandroid/gradle.propertiesandENV['RCT_NEW_ARCH_ENABLED'] = '0'in the iOS Podfile. However, always search for TurboModule-compatible package alternatives.
2. Project Structure and Architecture
- Organize all logic and screens in a "Feature-Based" folder structure. E.g.,
src/features/auth/,src/features/feed/. Each feature contains its ownapi/,components/,screens/. Global components should only be truly shared items (Button, Input, etc.).
3. Navigation (React Navigation v7)
- With v7's static type definitions, parameter passing is fully type-safe. Always narrow parameters with static types (TypeScript interfaces). Do not use "magic string" route names. Design modules (
stack,tab,drawer) in a modular fashion based on need.
4. Performance and Lists
- FlatList vs ScrollView: For lists with more content than the visible screen, NEVER use
ScrollView.map. Always useFlatList. For massive item counts, fine-tuneinitialNumToRenderandmaxToRenderPerBatchfor memory optimization. - Memoization: Do not wrap every component in
React.memo. Only applymemoto components with expensive props that re-render frequently on state changes (e.g., a single row in a list), anduseCallbackfor functions passed to them.
5. State Management
- Zustand: Ideal for async data and global state. Zero boilerplate.
- Store API responses and session information in Zustand, except for component-scoped temporary data (form grids).
6. Native APIs and Testing
- Always wrap
Linking.canOpenURLin try-catch for native links (mailto:, tel:, https:) or app-to-app communication. iOS requires Info.plist (LSApplicationQueriesSchemes). - Jest + RNTL: Integration approach over E2E.
render()the component, then trigger withfireEvent.pressand await the result:await waitFor(() => expect(screen.getByText('Success')).toBeTruthy());
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |