Skip to content

Commit 8250fab

Browse files
committed
Updating alert adapter
1 parent 6df6688 commit 8250fab

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

AlertAdapter.js

+10-20
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
1-
'use strict';
2-
3-
var { Platform } = require("react-native");
4-
var Alert;
1+
import React, { Platform } from "react-native";
2+
let { Alert } = React;
53

64
if (Platform.OS === "android") {
7-
var CodePushDialog = require("react-native").NativeModules.CodePushDialog;
5+
const { NativeModules: { CodePushDialog } } = React;
6+
87
Alert = {
9-
alert: function(title, message, buttons) {
8+
alert(title, message, buttons) {
109
if (buttons.length > 2) {
1110
throw "Can only show 2 buttons for Android dialog.";
1211
}
1312

14-
var button1Text = buttons[0] ? buttons[0].text : null;
15-
var button2Text = buttons[1] ? buttons[1].text : null;
13+
const button1Text = buttons[0] ? buttons[0].text : null,
14+
button2Text = buttons[1] ? buttons[1].text : null;
1615

1716
CodePushDialog.showDialog(
1817
title, message, button1Text, button2Text,
19-
(buttonPressedId) => {
20-
buttons[buttonPressedId].onPress && buttons[buttonPressedId].onPress();
21-
},
22-
(error) => {
23-
throw error;
24-
});
18+
(buttonId) => { buttons[buttonId].onPress && buttons[buttonId].onPress(); },
19+
(error) => { throw error; });
2520
}
2621
};
27-
} else if (Platform.OS === "ios") {
28-
var { AlertIOS } = require("react-native");
29-
Alert = AlertIOS;
3022
}
3123

32-
module.exports = {
33-
Alert: Alert
34-
}
24+
module.exports = { Alert };

0 commit comments

Comments
 (0)