React Native (Expo) — AI-Native Scaffolding
AI Context & Token Optimization (Zero-Hallucination Rules)
- Expo Managed Workflow ONLY: You are strictly BANNED from modifying
ios/orandroid/native folders,Podfile, orbuild.gradle. Native configuration causes massive AI hallucinations. Use Expo Config plugins instead. - Strict TypeScript: Pure JavaScript is banned. All components, props, and API responses must be strongly typed.
- Expo Router: Use file-based routing (
app/). It drastically reduces navigation boilerplate. - NativeWind: Use NativeWind (Tailwind for RN) over
StyleSheet.create. It reduces line count and token usage significantly.
Project Structure
project/
├── app/ # Expo Router file-based routing
│ ├── (auth)/ # Authentication flow
│ ├── (tabs)/ # Tab bar layout
│ └── _layout.tsx # Root layout / Providers
├── components/ # Reusable UI components
├── constants/ # Colors, Layout dimensions, Config
├── hooks/ # Custom React hooks
├── services/ # API clients and external services
├── store/ # Global state (Zustand)
└── assets/ # Images, fonts
Naming Conventions
- Components:
PascalCase(e.g.,PrimaryButton.tsx) - Hooks:
camelCasestarting withuse(e.g.,useColorScheme.ts) - Routes:
kebab-caseor exact URL match.
Architectural Patterns
- Expo Router: Use the
app/directory for routing. Use<Link>fromexpo-router. - Styling: NativeWind is mandatory. Keep styles inline as utility classes.
- State: Use
Zustand. Avoid Redux. - Safe Areas: Wrap top-level screen views in
SafeAreaViewfromreact-native-safe-area-context.
Universal DateTime Governance
- API Boundary: All datetime values received from the backend are epoch ms or ISO-8601 UTC strings. Normalize to epoch ms immediately upon receipt.
- Client Display: Format for the user's locale using
Intl.DateTimeFormatwithtimeZonefromexpo-localization. Never hardcode a timezone. - State: Store timestamps as epoch ms (number) in Zustand stores. Only convert to localized strings in component render functions.
- Offline Queue: Timestamps in offline mutation queues must be epoch ms to avoid timezone dependency when the device's locale changes.
Testing Strategies
- Framework:
Jest+@testing-library/react-native. - Approach: Test component rendering and user interactions natively.