- Home
- Skills
- Frontend & Web Apps
- react native view architecture
Works with the AI Agents you already use
react native view architecture
Standardize React Native screens by separating JSX, logic, styling, and types into a strict four-file folder structure.
Free
react native view architecture
Example session with this skill installed
Refactor this Profile screen. It has inline styles, a direct setAge call, and checks if the user is a minor inside the JSX to show a warning. Use the folder architecture.
- Read your context and instructions
- Compiled the react native view
- Generated the UI component
I have refactored the Profile screen into the requested four-file architecture. The business logic for checking age status is now encapsulated in the viewmodel, and all styling has been moved to a dedicated styles file.
Profile View Refactor
// src/views/Profile/types.ts
export type AgeStatus = 'minor' | 'adult';
export interface ProfileProps {
initialAge: number;
userName: string;
}
// src/views/Profile/viewmodel.ts
import { useState } from 'react';
import { AgeStatus } from './types';
export const useViewModel = ({ initialAge }: { initialAge: number }) => {
const [age, setAge] = useState(initialAge);
const ageStatus: AgeStatus = age < 18 ? 'minor' : 'adult';
const ageLabel = `Age: ${age}`;
return {
ageLabel,
ageStatus,
showWarning: ageStatus === 'minor',
onIncrementAge: () => setAge(prev => prev + 1),
};
};
// src/views/Profile/styles.ts
import { StyleSheet } from 'react-native';
import { AgeStatus } from './types';
export const styles = StyleSheet.create({
container: { padding: 20, backgroundColor: '#fff' },
warningText: { color: '#E11D48', fontWeight: 'bold' },
normalText: { color: '#1F2937' }
});
export const getTextStyle = (status: AgeStatus) =>
status === 'minor' ? styles.warningText : styles.normalText;
// src/views/Profile/index.tsx
import React from 'react';
import { View, Text, Button } from 'react-native';
import { useViewModel } from './viewmodel';
import { styles, getTextStyle } from './styles';
import { ProfileProps } from './types';
export const ProfileView = (props: ProfileProps) => {
const { ageLabel, ageStatus, showWarning, onIncrementAge } = useViewModel(props);
return (
<View style={styles.container}>
<Text style={getTextStyle(ageStatus)}>{ageLabel}</Text>
{showWarning && <Text style={styles.warningText}>Parental consent required</Text>}
<Button title="Birthday" onPress={onIncrementAge} />
</View>
);
};
Next steps
- Move any global
Usertypes used in this view to your sharedsrc/typesfolder. - Add a
renderHooktest forviewmodel.tsto verify theageStatuslogic. - Update your navigation config to point to the new
Profile/index.tsx.
index.tsx
TSX · React component
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
About this skill
Stop your agent from writing 400-line React Native screens that mix state, effects, decisions and inline styles in one file.
This skill structures every screen as a folder of up to four files, each with one job:
- index.tsx: JSX only. It renders what the viewmodel returns and decides nothing
- styles.ts: styling only, with theme tokens and no inline styles anywhere else
- viewmodel.ts: a useViewModel() hook with the state, effects and every decision
- types.ts: the view's own types, only when there are any
Where each line goes is a question, not a judgement call: does it decide WHAT the user sees, or HOW it looks?
What's included
- The rules for each file, with the reasoning behind them
- A "where does this line go?" table for the cases that are easy to get wrong
- "Actions, not setters": viewmodels expose onIncrement, never setQuantity, so the view can't write invalid state
- A complete example view, all four files, that compiles under strict TypeScript
- A step-by-step guide to split an existing large component into the four files without changing behavior
- Rules for reusable components and a checklist before delivering
Works with styled-components, StyleSheet or NativeWind. If your project already follows this pattern, the agent copies your exact conventions; if it doesn't, it asks before restructuring anything.
Pairs with react-native-design: one decides how a screen looks, the other where each line of code lives.
Free and open source (MIT): github.com/brunoviews/agent-skills
How to use
Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free forever
No account required to browse
Trust & safety
Security scanned
Verified clean 3 days ago
- Free to download with an account