react-native

Coding rules for building React Native mobile apps, a framework for creating iOS and Android apps with JavaScript or TypeScript.

In plain words
What is it for?
Use them when generating or reviewing React Native screens, navigation, styles, hooks, and native iOS or Android behaviour.
Why use it?
They give an agent consistent guidance for components, styling, navigation, and platform-specific code, helping avoid common mobile-app mistakes.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/nedcodes-ok/cursorrules-collection/react-native
Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collection
Per session 665 This file is loaded in full into every session.
When invoked 665 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00665 $0.00665
Opus 5 $0.00332 $0.00332
Sonnet 5 $0.00133 $0.00133
Haiku 4.5 $0.00067 $0.00067

Measured yesterday against content hash 2125708da5f6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

react-native scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

rules-mdc/frameworks/react-native.mdc · 61 lines

How it starts

The opening of the file, as written. The whole thing — 61 lines — stays where its author put it; the contents beside it link to each section on GitHub.

React Native Cursor Rules

You are an expert React Native developer. Follow these rules:

Components

  • Functional components only with TypeScript
  • Use View, Text, Pressable from react-native, not HTML elements
  • Never use TouchableOpacity or TouchableHighlight, use Pressable instead
  • Wrap all visible text in <Text> components, bare strings crash on Android
  • Platform-specific files: Component.ios.tsx / Component.android.tsx when needed
  • Keep components under 150 lines, extract custom hooks for logic

Styling

  • Use StyleSheet.create() for all styles, not inline objects
  • Never use percentage-based dimensions for critical layouts, use Dimensions or useWindowDimensions
  • Use flex for layouts, not absolute positioning unless truly necessary
  • Platform-specific styles via Platform.select() or Platform.OS checks
  • Avoid magic numbers, define spacing/sizing constants
  • Use gap property for spacing between flex children (RN 0.71+)
  • React Navigation is the standard. Use typed navigation with NativeStackNavigationProp
  • Define a root param list type and use it everywhere
  • Use useNavigation and useRoute hooks, not prop drilling
  • Deep linking: define linking config at the navigator level
  • Keep screen components thin, extract business logic into hooks

Performance

  • Use FlatList for lists, never ScrollView with .map() for dynamic data
  • Always provide keyExtractor returning a stable string ID
  • Memoize list items with React.memo and extract renderItem outside the component
  • Use useCallback for event handlers passed to list items
  • Avoid anonymous functions in renderItem
  • Images: use FastImage (or expo-image) for caching, specify dimensions
  • Minimize bridge crossings: batch state updates, avoid rapid setState in loops

State and Data

  • Use React Query / TanStack Query for server state
  • Zustand or Jotai for global client state, avoid Redux unless already in the project
  • AsyncStorage for small key-value persistence, MMKV for performance-critical storage
  • Never store sensitive data in AsyncStorage, use expo-secure-store or Keychain

Read the full file on GitHub · 61 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 61 lines · 665 tokens per session scan A 2125708da5f6

Subscribe to this mod's changes

react-native is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (37 stars, last pushed 6mo ago), licensed MIT. It adds 665 tokens to every session, about $0.0033 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.