| name | architecture |
| description | Review and structure React Native features for correct folder layout, navigation, deep linking, error boundaries, rendering safety, and code quality. Use when designing a new feature, reviewing structure, or isolating crashes. |
| version | 1.0.1 |
| platforms | ["ios","android"] |
| react-native-version | 0.76+ |
| tags | ["react-native","architecture","navigation","structure"] |
Architecture Skill
Applicability
- Platforms: iOS and Android
- React Native: 0.76+ (New Architecture interop assumed unless a checklist item says otherwise)
When to Use
- Designing the folder and module structure for a new feature
- Reviewing a pull request for structural or navigation issues
- Adding deep links or wiring screens into navigation
- Isolating crashes so one feature cannot take down the whole app
- Checking general code quality before merge
Guidance
Feature Structure
Navigation & Deep Linking
Incorrect:
const { itemId } = route.params;
const item = useItem(itemId);
Correct:
const itemId = route.params?.itemId;
if (!itemId) return <ErrorScreen message="Invalid link" />;
const item = useItem(itemId);
Rendering Safety
Incorrect:
{count && <Text>{count} items</Text>}
<Text>Hello {user.name}</Text> // crashes on Android if name is undefined
Correct:
{count > 0 && <Text>{count} items</Text>}
<Text>Hello {user?.name ?? 'Guest'}</Text>
Resilience & Error Boundaries
Incorrect:
export default function App() {
return <Navigator />;
}
Correct:
export default function App() {
return (
<ErrorBoundary fallback={<AppCrashScreen />}>
<Navigator />
</ErrorBoundary>
);
}
function SearchScreen() {
return (
<ErrorBoundary fallback={<SearchUnavailable />}>
<SearchContent />
</ErrorBoundary>
);
}
Code Quality
Anti-Patterns
| Anti-Pattern | Why It's Bad | Fix |
|---|
| Cross-feature imports | Tight coupling, hard to move or delete features | Share through shared/ only |
navigate called during render | Infinite loop | Move to useEffect or an event handler |
| Components defined inside components | Re-mounts every render, loses state | Define at module scope |
| Platform checks scattered everywhere | Hard to follow, easy to miss a case | Use .ios.ts / .android.ts files |
any type | Defeats TypeScript, hides bugs | Use proper types or unknown |
| Missing error boundary | One crash takes down the whole app | Error boundary per feature |
Pitfalls
- Error boundaries only catch render and lifecycle errors — not errors in event handlers or async code. Handle those explicitly.
- Deep links fire on both cold start and background resume; the two paths have different lifecycles and both need testing.
undefined rendered inside <Text> crashes on Android but silently works on iOS, so iOS-only testing misses it.
- Using array index as a list key causes the wrong items to re-render on reorder or delete.