Essential React Native UI & Interaction Components
July 1, 2025Essential React Native UI & Interaction Components
React Native provides a powerful set of built-in components for creating native mobile apps. Below is a detailed guide to the core UI and interaction components with practical examples and explanations of their importance.
📦 Core UI Components
1. View
The View
component is the fundamental building block for layout. It’s like a div
in HTML and is used to group other components.
<View style={{ padding: 20 }}>
<Text>Hello World!</Text>
</View>
2. Text
Used to display text in your app. You can style it with font size, color, alignment, etc.
<Text style={{ fontSize: 18, color: 'blue' }}>This is a text</Text>
3. Image
Displays images from local or remote sources.
<Image source={{ uri: 'https://example.com/image.jpg' }} style={{ width: 100, height: 100 }} />
4. ScrollView
Allows scrolling through long content. Useful for vertical layouts that don’t fit the screen.
<ScrollView>
<Text>Content...</Text>
</ScrollView>
5. FlatList
Efficient way to render lists with performance optimizations.
<FlatList
data={[{ key: 'Item 1' }, { key: 'Item 2' }]}
renderItem={({ item }) => <Text>{item.key}</Text>}
/>
6. TextInput
Captures user input like email, password, etc.
<TextInput placeholder="Enter your name" style={{ borderWidth: 1, padding: 10 }} />
7. Button
Triggers actions on press. Simple and native-looking.
<Button title="Click Me" onPress={() => alert('Clicked!')} />
8. Pressable
More flexible touch component with advanced interactions.
<Pressable onPress={() => console.log('Pressed')}>
<Text>Press here</Text>
</Pressable>
9. Modal
Displays content over the rest of the app. Useful for dialogs and popups.
<Modal visible={true} transparent={true}>
<View style={{ marginTop: 100 }}>
<Text>This is a modal</Text>
</View>
</Modal>
🎯 Interaction Components
1. Alert
Shows a system dialog with messages and actions.
Alert.alert("Warning", "Are you sure?")
2. BackHandler
Handles Android back button presses.
BackHandler.addEventListener('hardwareBackPress', () => {
// Custom logic
return true;
});
3. KeyboardAvoidingView
Moves UI elements above the keyboard when it appears.
<KeyboardAvoidingView behavior="padding">...</KeyboardAvoidingView>
📱 Animation Components
1. Animated
Creates complex animations for components.
const fadeAnim = useRef(new Animated.Value(0)).current;
Animated.timing(fadeAnim, {
toValue: 1,
duration: 1000,
useNativeDriver: true
}).start();
2. LayoutAnimation
Automatically animates layout changes.
LayoutAnimation.configureNext(LayoutAnimation.Presets.spring);
Blog
Supercharge Your PHP Enums with archtechx/enums
Jul 01, 2025
Supercharge Your PHP Enums with archtechx/enums PHP 8.1 introduced native enums—type‑safe sets of named values like statuses or roles. The arch...
Laravel 12.18.0 Update
Jun 17, 2025
Laravel 12.18.0 Update The Laravel team released version 12.18.0 with several cool updates: String encrypt() & decrypt() helpers are...
Is Laravel Slow? Optimize Queries & Indexes for Maximum Performance
Jul 20, 2025
A detailed, example-rich guide to avoid slowdowns in Laravel apps by optimizing data retrieval and employing indexing smartly. 1. 🧠 Fetch Only...
Mastering Laravel Context: Advanced Logging and Contextual Job Tracing
Jul 20, 2025
Laravel Context is one of the most powerful new features in Laravel 12. It allows you to attach contextual data (like user ID, IP address, request pat...
Laravel 12.19: Elegant Query Builders with PHP Attributes
Jul 07, 2025
Laravel 12.19: Elegant Query Builders with PHP Attributes In Laravel 12.19, you can now use the #[UseEloquentBuilder] PHP attribute to assign a cus...
What’s New in ECMAScript 2025
Jun 30, 2025
What’s New in ECMAScript 2025 On June 25, 2025, Ecma International officially approved ES2025, adding several useful features: 1. 📦 Import At...
