React-native alert dialog box

React-native alert dialog

Hi Guys, In this article, we are going to learn about react-native alert dialog box, React-native use Operating system theme to display alert dialogs means, in Android device dialog displays like android default alert dialogs and in iOS device dialog displays like android default alert dialogs, in this article we are exploring different types of the alert dialog box, for this React-native provide inbuild component i.e. Alert. we have to import this component from react-native let’s see with an example,

React-native alert dialog

1. Create a new project

Create a new project using the following command, In my case, I am using my previous project

2. Import the following components

3. Function for single option alert dialog

As you saw above there is the first string is Alert dialog title and the second string is the message.

4. Function to display two options alert dialog

This is two options alert dialog it displays two buttons

5. Function for three options alert dialog react-native

The above function display three button options

Let’s see the full source code for the same

6. Source code alert dialog box

As you can see in the above source code, I have used three buttons and call arrow functions to display the react-native alert dialog box.

7. OutputsReact-native alert dialog box

React-native alert dialog boxReact-native alert dialog box

Thank you 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *