NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 8

Button and onPress event in react native.

In React Native, buttons are created using the Button component, and you can handle button presses using the onPress prop.

Here's is the Code !!

import React from 'react';
import { View, Button, Alert } from 'react-native';

const App = () => {
  const handlePress = () => {
    Alert.alert('Button Pressed', 'You pressed the button!', [
      { text: 'OK', onPress: () => console.log('OK Pressed') }
    ]);
  };

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Button title="Press Me" onPress={handlePress} />
    </View>
  );
};

export default App;

Chapter 7

What is component in react native.

Previous chapter

Chapter 9

State in react native | State vs Variables

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

© www.thecoderjob.com. All Rights Reserved.               Designed by HTML Codex