Building Reusable React Native Components with TypeScript
When several screens use the same button, status label, or card layout, copying JSX is fast at first but expensive to maintain. A reusable component helps keep behavior and visual details consistent.
The goal is not to create a large design system on day one. Start with small components that solve a repeated problem and give them clear TypeScript props.
Start with a real use case
Imagine an app that has a primary action on its login, profile, and checkout screens. Each action needs:
- A label
- A press handler
- A disabled state
- A loading state
Rather than repeating a Pressable, create one reusable AppButton.
Build a typed button
Create components/AppButton.tsx:
import {ActivityIndicator, Pressable, StyleSheet, Text} from 'react-native';
type AppButtonProps = {
title: string;
onPress: () => void;
disabled?: boolean;
loading?: boolean;
};
export function AppButton({
title,
onPress,
disabled = false,
loading = false,
}: AppButtonProps) {
const unavailable = disabled || loading;
return (
<Pressable
accessibilityRole="button"
accessibilityLabel={title}
accessibilityState={{disabled: unavailable, busy: loading}}
disabled={unavailable}
onPress={onPress}
style={({pressed}) => [
styles.button,
pressed && !unavailable && styles.pressed,
unavailable && styles.disabled,
]}>
{loading ? (
<ActivityIndicator color="#fff" />
) : (
<Text style={styles.label}>{title}</Text>
)}
</Pressable>
);
}
const styles = StyleSheet.create({
button: {
minHeight: 48,
borderRadius: 10,
backgroundColor: '#155eef',
alignItems: 'center',
justifyContent: 'center',
paddingHorizontal: 16,
},
label: {
color: '#fff',
fontSize: 16,
fontWeight: '600',
},
pressed: {opacity: 0.85},
disabled: {opacity: 0.5},
});
Several details make this more useful than a visual wrapper:
- Optional props have predictable defaults.
- Loading and disabled states both prevent duplicate presses.
accessibilityRoleandaccessibilityStatecommunicate the control's purpose and current state.- The component owns its default styling, so screens stay focused on layout and behavior.
Use the component from a screen
import {useState} from 'react';
import {View} from 'react-native';
import {AppButton} from './components/AppButton';
export function ProfileScreen() {
const [saving, setSaving] = useState(false);
async function saveProfile() {
setSaving(true);
try {
// Replace this with your API or persistence call.
await Promise.resolve();
} finally {
setSaving(false);
}
}
return (
<View style={{padding: 20}}>
<AppButton
title="Save profile"
loading={saving}
onPress={saveProfile}
/>
</View>
);
}
The button does not need to know how profiles are saved. It only needs to present the state provided by its parent.
Use a union when variants are limited
Suppose the design needs two approved styles: primary and secondary. Avoid allowing an arbitrary string:
type ButtonVariant = 'primary' | 'secondary';
type ButtonProps = {
title: string;
variant?: ButtonVariant;
onPress: () => void;
};
This makes invalid variants a TypeScript error and gives the team a manageable visual vocabulary. You can then map each variant to styles in StyleSheet.create.
However, do not add dozens of variants just in case they might be useful. Add a prop only when a real screen needs the behavior.
Accept styles only when flexibility is needed
Some components need to fill their parent's width or sit inside different layouts. You can expose a typed container style:
import type {StyleProp, ViewStyle} from 'react-native';
type CardProps = {
children: React.ReactNode;
style?: StyleProp<ViewStyle>;
};
Use StyleProp<ViewStyle> for a View container rather than any. For text styling, use StyleProp<TextStyle>.
One limitation: a style prop only changes appearance, not component behavior. Prefer explicit props for meaningful states such as loading, disabled, or selected.
Prefer composition over complicated prop sets
A card component is a good candidate for composition because different screens may put different content inside it:
import type {ReactNode} from 'react';
import {StyleSheet, View} from 'react-native';
type AppCardProps = {
children: ReactNode;
};
export function AppCard({children}: AppCardProps) {
return <View style={styles.card}>{children}</View>;
}
const styles = StyleSheet.create({
card: {
padding: 16,
borderRadius: 12,
backgroundColor: '#f1f5f9',
},
});
A parent screen can place any combination of text, images, or actions inside AppCard without forcing the card to have props for every possible child.
When should a component be reusable?
Extract a component when it offers at least one clear advantage:
- The same behavior appears on several screens.
- A repeated UI pattern must stay visually consistent.
- A piece of UI has enough complexity to be easier to test or reason about separately.
Avoid extracting every View or Text just to make files shorter. A component with an unclear purpose and too many configuration props often becomes harder to maintain than a small amount of duplication.
Practical checklist
Before sharing a component across the app, ask:
- Are the prop names understandable without reading the implementation?
- Are optional props truly optional and given sensible defaults?
- Are loading, disabled, empty, and error states handled where applicable?
- Is the control accessible to screen-reader and keyboard users where appropriate?
- Does TypeScript prevent common invalid combinations?
- Can the component evolve without affecting unrelated screens?
Start small: a good button, card, input field, or empty-state component can offer immediate value. Build a larger design system only when real usage reveals consistent patterns worth standardizing.