The RNFancyAlert API consists of:
RNFancyAlert object (in an imperative way)RNFancyAlert component instance; they act as defaults for all Alerts that are shownalert(options)To open an Alert, call the alert() method and pass the options that suit your needs. title is required but other options are optional
import RnFancyAlert from 'react-native-fancy-alert'
RNFancyAlert.alert({
title: 'Hello Alert',
subtitle: 'This is an alert'
});
The complete set of options is described below:
| option | description | type | default value |
|---|---|---|---|
title |
Title of the alert, It can be plain string or any React ComponentLearn how to customize title | string|ReactNativeElement |
Alert |
subtitle |
Alert body | string |
|
buttons |
RNAlertButtons | array[RNAlertButton] |
RNAlertTitleRNAlertTitle is the view component which holds the title and we can pass plain string or any ReactNative Component as title. title option is rendered as child of RNAlertTitle.
RNAlertSubtitleRNAlertSubtitle is the view component which holds the subtitle or message body and we can pass plain string or any ReactNative Component as subtitle. subtitle option is rendered as child of RNAlertSubtitle.
RNAlertButtonsRNAlertButtons holds the action buttons passed to the alert, It holds the array of RNAlertButton and It shows a button with text Ok by default.
RNAlertButtonRNAlertButton holds the individual button object and we can pass following button options from alert method of RNFancyAlert:
| option | description | type | default value |
|---|---|---|---|
title |
Title of the button, it can be plain text or any React Native ComponentLearn how to customize title | string|ReactNativeElement |
|
role |
Role of the button, valid option is cancel |
string |
|
type |
success or warning or error or default |
string |
default |
onPress |
Called when the button is pressed | () => void |