Skip to content

Commit 485a216

Browse files
committed
Replace alert with Alert API
1 parent 6b6a27c commit 485a216

File tree

6 files changed

+30
-15
lines changed

6 files changed

+30
-15
lines changed

RNTester/js/AccessibilityIOSExample.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@
1212

1313
const React = require('react');
1414
const ReactNative = require('react-native');
15-
const {AccessibilityInfo, Text, View, TouchableOpacity} = ReactNative;
15+
const {AccessibilityInfo, Text, View, TouchableOpacity, Alert} = ReactNative;
1616

1717
class AccessibilityIOSExample extends React.Component<{}> {
1818
render() {
1919
return (
2020
<View>
2121
<View
22-
onAccessibilityTap={() => alert('onAccessibilityTap success')}
22+
onAccessibilityTap={() =>
23+
Alert.alert('Alert', 'onAccessibilityTap success')
24+
}
2325
accessible={true}>
2426
<Text>Accessibility normal tap example</Text>
2527
</View>
26-
<View onMagicTap={() => alert('onMagicTap success')} accessible={true}>
28+
<View
29+
onMagicTap={() => Alert.alert('Alert', 'onMagicTap success')}
30+
accessible={true}>
2731
<Text>Accessibility magic tap example</Text>
2832
</View>
2933
<View accessibilityLabel="Some announcement" accessible={true}>

RNTester/js/ActionSheetIOSExample.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212

1313
const React = require('react');
1414
const ReactNative = require('react-native');
15-
const {ActionSheetIOS, StyleSheet, takeSnapshot, Text, View} = ReactNative;
15+
const {
16+
ActionSheetIOS,
17+
StyleSheet,
18+
takeSnapshot,
19+
Text,
20+
View,
21+
Alert,
22+
} = ReactNative;
1623

1724
const BUTTONS = ['Option 0', 'Option 1', 'Option 2', 'Delete', 'Cancel'];
1825
const DESTRUCTIVE_INDEX = 3;
@@ -106,7 +113,7 @@ class ShareActionSheetExample extends React.Component<
106113
subject: 'a subject to go in the email heading',
107114
excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'],
108115
},
109-
error => alert(error),
116+
error => Alert.alert('Error', error),
110117
(completed, method) => {
111118
let text;
112119
if (completed) {
@@ -146,7 +153,7 @@ class ShareScreenshotExample extends React.Component<{}, $FlowFixMeState> {
146153
url: uri,
147154
excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'],
148155
},
149-
error => alert(error),
156+
error => Alert.alert('Error', error),
150157
(completed, method) => {
151158
let text;
152159
if (completed) {
@@ -158,7 +165,7 @@ class ShareScreenshotExample extends React.Component<{}, $FlowFixMeState> {
158165
},
159166
);
160167
})
161-
.catch(error => alert(error));
168+
.catch(error => Alert.alert('Error', error));
162169
};
163170
}
164171

RNTester/js/GeolocationExample.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
const React = require('react');
1414
const ReactNative = require('react-native');
15-
const {StyleSheet, Text, View} = ReactNative;
15+
const {StyleSheet, Text, View, Alert} = ReactNative;
1616

1717
exports.framework = 'React';
1818
exports.title = 'Geolocation';
@@ -41,7 +41,7 @@ class GeolocationExample extends React.Component<{}, $FlowFixMeState> {
4141
const initialPosition = JSON.stringify(position);
4242
this.setState({initialPosition});
4343
},
44-
error => alert(JSON.stringify(error)),
44+
error => Alert.alert('Error', JSON.stringify(error)),
4545
{enableHighAccuracy: true, timeout: 20000, maximumAge: 1000},
4646
);
4747
this.watchID = navigator.geolocation.watchPosition(position => {

RNTester/js/MultiColumnExample.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
const React = require('react');
1414
const ReactNative = require('react-native');
15-
const {FlatList, StyleSheet, Text, View} = ReactNative;
15+
const {FlatList, StyleSheet, Text, View, Alert} = ReactNative;
1616

1717
const RNTesterPage = require('./RNTesterPage');
1818

@@ -91,7 +91,9 @@ class MultiColumnExample extends React.PureComponent<
9191
data={filteredData}
9292
key={this.state.numColumns + (this.state.fixedHeight ? 'f' : 'v')}
9393
numColumns={this.state.numColumns || 1}
94-
onRefresh={() => alert('onRefresh: nothing to refresh :P')}
94+
onRefresh={() =>
95+
Alert.alert('Alert', 'onRefresh: nothing to refresh :P')
96+
}
9597
refreshing={false}
9698
renderItem={this._renderItemComponent}
9799
disableVirtualization={!this.state.virtualized}

RNTester/js/TextInputExample.ios.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Button = require('Button');
1414
const InputAccessoryView = require('InputAccessoryView');
1515
const React = require('react');
1616
const ReactNative = require('react-native');
17-
const {Text, TextInput, View, StyleSheet, Slider, Switch} = ReactNative;
17+
const {Text, TextInput, View, StyleSheet, Slider, Switch, Alert} = ReactNative;
1818

1919
class WithLabel extends React.Component<$FlowFixMeProps> {
2020
render() {
@@ -862,7 +862,9 @@ exports.examples = [
862862
returnKeyType="next"
863863
blurOnSubmit={true}
864864
multiline={true}
865-
onSubmitEditing={event => alert(event.nativeEvent.text)}
865+
onSubmitEditing={event =>
866+
Alert.alert('Alert', event.nativeEvent.text)
867+
}
866868
/>
867869
</View>
868870
);

RNTester/js/TransparentHitTestExample.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
const React = require('react');
1414
const ReactNative = require('react-native');
15-
const {Text, View, TouchableOpacity} = ReactNative;
15+
const {Text, View, TouchableOpacity, Alert} = ReactNative;
1616

1717
class TransparentHitTestExample extends React.Component<{}> {
1818
render() {
1919
return (
2020
<View style={{flex: 1}}>
21-
<TouchableOpacity onPress={() => alert('Hi!')}>
21+
<TouchableOpacity onPress={() => Alert.alert('Alert', 'Hi!')}>
2222
<Text>HELLO!</Text>
2323
</TouchableOpacity>
2424

0 commit comments

Comments
 (0)