code-conventions-rn
Code Conventions - React Native / TypeScript
Section titled “Code Conventions - React Native / TypeScript”Extends core code-conventions.md. The1Studio-specific patterns.
Naming
Section titled “Naming”- Components: PascalCase, no suffix:
Card,UserAvatar - Hooks:
use*prefix:useDebounce,useFetch - Stores:
use{Name}Store.ts:useAuthStore.ts - Atoms:
{name}Atom.ts:themeAtom.ts - Services:
{domain}.service.ts:auth.service.ts - Types:
{name}.types.ts:user.types.ts - Constants:
UPPER_SNAKE_CASE - Folders:
kebab-case
Language & Tooling
Section titled “Language & Tooling”- TypeScript strict mode:
strict: true, noanywithout comment, no@ts-ignore - Expo managed workflow: no bare ejecting unless explicitly required
- Node: LTS version pinned via
.nvmrc
Project Structure
Section titled “Project Structure”- Expo Router for all navigation: file-based routing under
app/ - Path alias
@/for all imports: never relative../../ - Feature folders:
features/auth/,features/profile/ - Shared:
components/,hooks/,store/,services/,constants/,types/,utils/
State Management
Section titled “State Management”- Zustand for global app state (auth, settings)
- Jotai for fine-grained reactive atoms
- Local
useStatefor UI-only state - Zustand selectors:
useStore((s) => s.field): neveruseStore()(causes over-rendering) expo-secure-storefor tokens: NEVER AsyncStorage for sensitive data- MMKV for fast sync access (requires dev build, not Expo Go)
Styling
Section titled “Styling”StyleSheet.create()for all styles: never inline style objectsuseColorScheme()+ theme tokens for dark/light modeuseSafeAreaInsets(): never hardcode status bar heightsuseWindowDimensions(): neverDimensions.get()(not reactive)
Components & Performance
Section titled “Components & Performance”memo()on all FlatList/FlashList render item componentsuseCallbackfor handlers passed as props to memoized childrenFlashListfor lists > 50 itemsPressableoverTouchableOpacity(modern, flexible API)expo-constantsfor environment config: never hardcode URLs
Testing & Build
Section titled “Testing & Build”- Jest + RNTL; tests in
__tests__/mirroring source (not.test.tsxin same folder) - EAS Build only: never manual Xcode/Android Studio; credentials in EAS, never committed
Living Document
Section titled “Living Document”If unsure about a convention not covered here, ask the user for their preference and update this file with the answer. Conventions grow from real decisions.