React Native
react-nativeMobile51 lines
Cross-platform iOS and Android apps from one TypeScript codebase.
Current — as published in v1.3.2. Written by hand for React Native, not generated.
The rule
Components
- Function components with typed props. No class components.
- One screen per file; extract a component once a screen passes ~150 lines.
StyleSheet.createat the bottom of the file — never inline style objects in render, which allocates a new object every frame.- Platform differences go in
Platform.select, or a.ios.tsx/.android.tsxpair when the whole component differs.
Layout
- Flexbox only.
flexDirectiondefaults tocolumn— the opposite of the web. - Never hardcode screen dimensions. Use flex,
useWindowDimensions, andSafeAreaViewfor notches and home indicators. - Wrap text in
<Text>. A bare string inside<View>crashes at runtime.
Lists
FlatListorFlashList, never.map()over fetched data — an unvirtualised list of 500 rows mounts 500 components.keyExtractorreturns a stable id, not the index.- Memoise
renderItemand keep row components pure, or every parent render re-renders every visible row.
Images
- Always give remote images explicit
width/height; without them layout jumps when they load. - Ship assets at display size. A 4000px source scaled into a 100px avatar costs full decode memory on every render.
Platform APIs
- Request permissions immediately before the action that needs them, with an explanation — not on app start.
- Handle the denied case as a real UI state, not an alert-and-hope.
- Anything touching the native layer goes behind a service, so it can be mocked.
Performance
- Profile in a release build; debug builds are misleading.
- Keep
useEffectdependency arrays honest. Do not disable the lint rule. - Clean up subscriptions, timers and listeners on unmount.
Never
- Never edit
ios/orandroid/generated files by hand. - Never leave
console.login shipped code. - Never assume a JS reload picks up a native module change — rebuild.
As each tool receives it
The same guidance, in the shape each editor reads. Cursor and Claude Code are written separately by hand; the rest are derived from the Cursor rule.
.cursor/rules/react-native.mdc
---
description: React Native conventions
globs: ["**/*.tsx", "src/**/*.ts"]
alwaysApply: false
---
# React Native
## Components
- Function components with typed props. No class components.
- One screen per file; extract a component once a screen passes ~150 lines.
- `StyleSheet.create` at the bottom of the file — never inline style objects in
render, which allocates a new object every frame.
- Platform differences go in `Platform.select`, or a `.ios.tsx` / `.android.tsx`
pair when the whole component differs.
## Layout
- Flexbox only. `flexDirection` defaults to `column` — the opposite of the web.
- Never hardcode screen dimensions. Use flex, `useWindowDimensions`, and
`SafeAreaView` for notches and home indicators.
- Wrap text in `<Text>`. A bare string inside `<View>` crashes at runtime.
## Lists
- `FlatList` or `FlashList`, never `.map()` over fetched data — an unvirtualised
list of 500 rows mounts 500 components.
- `keyExtractor` returns a stable id, not the index.
- Memoise `renderItem` and keep row components pure, or every parent render
re-renders every visible row.
## Images
- Always give remote images explicit `width`/`height`; without them layout jumps
when they load.
- Ship assets at display size. A 4000px source scaled into a 100px avatar costs
full decode memory on every render.
## Platform APIs
- Request permissions immediately before the action that needs them, with an
explanation — not on app start.
- Handle the denied case as a real UI state, not an alert-and-hope.
- Anything touching the native layer goes behind a service, so it can be mocked.
## Performance
- Profile in a release build; debug builds are misleading.
- Keep `useEffect` dependency arrays honest. Do not disable the lint rule.
- Clean up subscriptions, timers and listeners on unmount.
## Never
- Never edit `ios/` or `android/` generated files by hand.
- Never leave `console.log` in shipped code.
- Never assume a JS reload picks up a native module change — rebuild.
What else this module writes
Selecting React Native contributes more than a rule file — all of it merged with every other module you pick, with conflicts resolved rather than duplicated.
Dependencies
react^19.2.3react-native^0.86.0react-native-safe-area-context^5.8.0react-native-screens^4.26.0@types/react^19.2.0dev
Folders
src/components/src/features/src/hooks/src/navigation/src/services/src/theme/src/utils/assets/images/assets/fonts/
Put this in your repo
Adds React Native to a project this tool generated, without starting over. Files you have hand-edited are left alone.