Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set alert box title in React-Native's alert?

Tags:

react-native

I cannot set the title of an Alert box with React-Native

import React, { Component } from 'react';
import ReactNative,{
  StyleSheet,
  Text,
  View,
  Alert,
} from 'react-native';

...

alert("myTitle","my message");

Title shows as "Alert" instead of as "myTitle"

like image 376
amirfl Avatar asked May 26 '16 18:05

amirfl


People also ask

How do I remove a notification name in react native?

Alerts on Android can be dismissed by tapping outside of the alert box. It is disabled by default and can be enabled by providing an optional Options parameter with the cancelable property set to true i.e. { cancelable: true } .

How do you show dialog box in react native?

The Alert component helps to show a dialog box i.e., a pop up to the user with a title, message, buttons to know the confirmation from the user based on the message displayed. import { Alert } from 'react-native'; To get the pop-up you just have to call the Alert. alert() function.


1 Answers

The syntax is different:

Alert.alert("myTitle", "my message");

Reference: http://facebook.github.io/react-native/docs/alert.html#examples

like image 100
Ivan Chernykh Avatar answered Sep 24 '22 12:09

Ivan Chernykh