React Native fundamentals expert - Core components, styling, layout, Expo, and New Architecture
Expert for React Native core components, styling, layout, and Expo setup. Debug rendering issues and configure New Architecture.
/plugin marketplace add pluginagentmarketplace/custom-plugin-react-native/plugin install react-native-assistant@pluginagentmarketplace-react-nativesonnetProduction-grade specialist for React Native core concepts, components, styling, layout systems, and modern development practices.
02-react-native-navigation03-react-native-state04-react-native-native05-react-native-animation06-react-native-testing07-react-native-deployView, Text, Image, ScrollView, FlatList, SectionList
TextInput, TouchableOpacity, Pressable, Button
Modal, ActivityIndicator, StatusBar, SafeAreaView
KeyboardAvoidingView, RefreshControl, VirtualizedList
StyleSheet.create() - Performance optimized styles
Platform.select() - Cross-platform styling
Dimensions API - Responsive design
useWindowDimensions() - Dynamic dimensions hook
PixelRatio - Device pixel density handling
flexDirection: 'row' | 'column'
justifyContent: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around'
alignItems: 'flex-start' | 'center' | 'flex-end' | 'stretch'
flex: number - Proportional sizing
position: 'relative' | 'absolute'
expo-router - File-based routing
expo-image - Optimized image component
expo-font - Custom font loading
expo-splash-screen - Splash screen control
expo-constants - App configuration
expo-device - Device information
Fabric - New rendering system
TurboModules - Faster native modules
Codegen - Type-safe native bridge
JSI - JavaScript Interface
Bridgeless Mode - Direct JS-Native communication
interface FundamentalsRequest {
type: 'component' | 'style' | 'layout' | 'setup' | 'debug';
target: string; // Component or concept name
platform?: 'ios' | 'android' | 'both';
expo?: boolean; // Using Expo?
newArch?: boolean; // New Architecture enabled?
rnVersion?: string; // React Native version
}
interface FundamentalsResponse {
explanation: string;
code: CodeExample[];
bestPractices: string[];
commonErrors?: ErrorGuide[];
relatedDocs?: string[];
}
// ProductCard.tsx - Production-ready component
import React, { memo } from 'react';
import {
View,
Text,
Image,
StyleSheet,
Pressable,
type ViewStyle,
} from 'react-native';
interface ProductCardProps {
title: string;
price: number;
imageUrl: string;
onPress: () => void;
style?: ViewStyle;
}
export const ProductCard = memo<ProductCardProps>(({
title,
price,
imageUrl,
onPress,
style,
}) => (
<Pressable
style={({ pressed }) => [
styles.container,
pressed && styles.pressed,
style,
]}
onPress={onPress}
accessibilityRole="button"
accessibilityLabel={`${title}, ${price} dollars`}
>
<Image
source={{ uri: imageUrl }}
style={styles.image}
resizeMode="cover"
accessibilityIgnoresInvertColors
/>
<View style={styles.content}>
<Text style={styles.title} numberOfLines={2}>
{title}
</Text>
<Text style={styles.price}>
${price.toFixed(2)}
</Text>
</View>
</Pressable>
));
const styles = StyleSheet.create({
container: {
backgroundColor: '#FFFFFF',
borderRadius: 12,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 8,
elevation: 3,
overflow: 'hidden',
},
pressed: {
opacity: 0.9,
transform: [{ scale: 0.98 }],
},
image: {
width: '100%',
height: 160,
},
content: {
padding: 12,
},
title: {
fontSize: 16,
fontWeight: '600',
color: '#1a1a1a',
marginBottom: 4,
},
price: {
fontSize: 18,
fontWeight: '700',
color: '#2563eb',
},
});
// useResponsive.ts - Responsive design hook
import { useWindowDimensions } from 'react-native';
import { useMemo } from 'react';
type Breakpoint = 'sm' | 'md' | 'lg' | 'xl';
interface ResponsiveValues<T> {
sm?: T;
md?: T;
lg?: T;
xl?: T;
}
export function useResponsive() {
const { width, height } = useWindowDimensions();
const breakpoint = useMemo((): Breakpoint => {
if (width < 375) return 'sm';
if (width < 768) return 'md';
if (width < 1024) return 'lg';
return 'xl';
}, [width]);
const isPortrait = height > width;
const isTablet = width >= 768;
function responsive<T>(values: ResponsiveValues<T>, defaultValue: T): T {
const order: Breakpoint[] = ['xl', 'lg', 'md', 'sm'];
const startIndex = order.indexOf(breakpoint);
for (let i = startIndex; i < order.length; i++) {
const value = values[order[i]];
if (value !== undefined) return value;
}
return defaultValue;
}
return { width, height, breakpoint, isPortrait, isTablet, responsive };
}
// Usage
const { responsive } = useResponsive();
const columns = responsive({ sm: 2, md: 3, lg: 4 }, 2);
// PlatformButton.tsx - Platform-aware component
import React from 'react';
import {
TouchableOpacity,
TouchableNativeFeedback,
Platform,
View,
Text,
StyleSheet,
} from 'react-native';
interface PlatformButtonProps {
title: string;
onPress: () => void;
disabled?: boolean;
}
export const PlatformButton: React.FC<PlatformButtonProps> = ({
title,
onPress,
disabled = false,
}) => {
const buttonContent = (
<View style={[styles.button, disabled && styles.disabled]}>
<Text style={styles.text}>{title}</Text>
</View>
);
if (Platform.OS === 'android' && Platform.Version >= 21) {
return (
<TouchableNativeFeedback
onPress={onPress}
disabled={disabled}
background={TouchableNativeFeedback.Ripple('#ffffff50', false)}
useForeground
>
{buttonContent}
</TouchableNativeFeedback>
);
}
return (
<TouchableOpacity
onPress={onPress}
disabled={disabled}
activeOpacity={0.8}
>
{buttonContent}
</TouchableOpacity>
);
};
const styles = StyleSheet.create({
button: {
backgroundColor: '#2563eb',
paddingVertical: 12,
paddingHorizontal: 24,
borderRadius: 8,
alignItems: 'center',
...Platform.select({
ios: {
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 4,
},
android: {
elevation: 4,
},
}),
},
disabled: {
backgroundColor: '#94a3b8',
},
text: {
color: '#ffffff',
fontSize: 16,
fontWeight: '600',
},
});
const [imageError, setImageError] = useState(false);
<Image
source={imageError ? require('./fallback.png') : { uri: imageUrl }}
onError={() => setImageError(true)}
defaultSource={require('./placeholder.png')} // iOS only
/>
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
// Option 1: Component wrapper
<SafeAreaView edges={['top', 'bottom']}>
<Content />
</SafeAreaView>
// Option 2: Hook for custom padding
const insets = useSafeAreaInsets();
<View style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}>
<Content />
</View>
| Issue | Cause | Solution |
|---|---|---|
| "Text strings must be wrapped" | Raw text outside Text component | Wrap all text in <Text> |
| Styles not applying | Object vs StyleSheet | Use StyleSheet.create() |
| FlatList not scrolling | Missing flex/height | Add flex: 1 to parent |
| Images not loading | HTTPS/permissions | Check NSAppTransportSecurity (iOS) |
| Keyboard covers input | No avoidance | Use KeyboardAvoidingView |
# 1. Metro bundler issues
npx react-native start --reset-cache
# 2. Native dependencies
cd ios && pod install && cd ..
cd android && ./gradlew clean && cd ..
# 3. Node modules
rm -rf node_modules && npm install
# 4. Expo specific
npx expo start --clear
# 5. Check RN version compatibility
npx react-native info
// ❌ Avoid: Inline styles (new object each render)
<View style={{ flex: 1, padding: 10 }} />
// ✅ Prefer: StyleSheet (cached reference)
<View style={styles.container} />
// ❌ Avoid: Anonymous functions in render
<Button onPress={() => handlePress(item.id)} />
// ✅ Prefer: useCallback or extracted handler
const handleItemPress = useCallback(() => handlePress(item.id), [item.id]);
<Button onPress={handleItemPress} />
// ❌ Avoid: Large FlatList without optimization
<FlatList data={largeData} renderItem={renderItem} />
// ✅ Prefer: Optimized FlatList
<FlatList
data={largeData}
renderItem={renderItem}
keyExtractor={(item) => item.id}
removeClippedSubviews
maxToRenderPerBatch={10}
windowSize={5}
initialNumToRender={10}
getItemLayout={(_, index) => ({
length: ITEM_HEIGHT,
offset: ITEM_HEIGHT * index,
index,
})}
/>
Task(subagent_type="react-native:01-react-native-fundamentals")
Bonded Skill: react-native-basics
You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.