React Native – Button
Button
is a basic component for handling user interactions. It renders a native button and supports custom text and onPress handling.
Use Cases:
- Simple user interactions like submitting a form, triggering actions, or navigating to different screens.
Example:
import React from 'react';
import { View, Button, Alert, StyleSheet } from 'react-native';
const App = () => {
return (
<View style={styles.container}>
<Button
title="Press me"
onPress={() => Alert.alert('Button pressed!')}
/>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
export default App;