From 55994f5900d1ddb92bc9c37d085d6ac15b1692f8 Mon Sep 17 00:00:00 2001 From: Victor Calvello Date: Mon, 19 Nov 2018 18:06:49 -0800 Subject: [PATCH] Replace global.alert use to fix eslint warnings (#22184) Summary: Replaces `alert` with `Alert.alert` to fix eslint warnings. Pull Request resolved: https://github.com/facebook/react-native/pull/22184 Reviewed By: TheSavior Differential Revision: D13105636 Pulled By: RSNara fbshipit-source-id: 82a9e55fd002051e3cf8238e29d37b2b33f66f0e --- RNTester/js/AccessibilityIOSExample.js | 10 +++++++--- RNTester/js/ActionSheetIOSExample.js | 15 +++++++++++---- RNTester/js/GeolocationExample.js | 4 ++-- RNTester/js/MultiColumnExample.js | 6 ++++-- RNTester/js/TextInputExample.ios.js | 6 ++++-- RNTester/js/TransparentHitTestExample.js | 4 ++-- 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/RNTester/js/AccessibilityIOSExample.js b/RNTester/js/AccessibilityIOSExample.js index fcae4284450022..96ed8fc39fc31c 100644 --- a/RNTester/js/AccessibilityIOSExample.js +++ b/RNTester/js/AccessibilityIOSExample.js @@ -12,18 +12,22 @@ const React = require('react'); const ReactNative = require('react-native'); -const {AccessibilityInfo, Text, View, TouchableOpacity} = ReactNative; +const {AccessibilityInfo, Text, View, TouchableOpacity, Alert} = ReactNative; class AccessibilityIOSExample extends React.Component<{}> { render() { return ( alert('onAccessibilityTap success')} + onAccessibilityTap={() => + Alert.alert('Alert', 'onAccessibilityTap success') + } accessible={true}> Accessibility normal tap example - alert('onMagicTap success')} accessible={true}> + Alert.alert('Alert', 'onMagicTap success')} + accessible={true}> Accessibility magic tap example diff --git a/RNTester/js/ActionSheetIOSExample.js b/RNTester/js/ActionSheetIOSExample.js index 36e3d9e81da10a..1a524859613a7d 100644 --- a/RNTester/js/ActionSheetIOSExample.js +++ b/RNTester/js/ActionSheetIOSExample.js @@ -12,7 +12,14 @@ const React = require('react'); const ReactNative = require('react-native'); -const {ActionSheetIOS, StyleSheet, takeSnapshot, Text, View} = ReactNative; +const { + ActionSheetIOS, + StyleSheet, + takeSnapshot, + Text, + View, + Alert, +} = ReactNative; const BUTTONS = ['Option 0', 'Option 1', 'Option 2', 'Delete', 'Cancel']; const DESTRUCTIVE_INDEX = 3; @@ -106,7 +113,7 @@ class ShareActionSheetExample extends React.Component< subject: 'a subject to go in the email heading', excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'], }, - error => alert(error), + error => Alert.alert('Error', error), (completed, method) => { let text; if (completed) { @@ -146,7 +153,7 @@ class ShareScreenshotExample extends React.Component<{}, $FlowFixMeState> { url: uri, excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'], }, - error => alert(error), + error => Alert.alert('Error', error), (completed, method) => { let text; if (completed) { @@ -158,7 +165,7 @@ class ShareScreenshotExample extends React.Component<{}, $FlowFixMeState> { }, ); }) - .catch(error => alert(error)); + .catch(error => Alert.alert('Error', error)); }; } diff --git a/RNTester/js/GeolocationExample.js b/RNTester/js/GeolocationExample.js index f659b7c4afc5ba..8ed2182ecd9294 100644 --- a/RNTester/js/GeolocationExample.js +++ b/RNTester/js/GeolocationExample.js @@ -12,7 +12,7 @@ const React = require('react'); const ReactNative = require('react-native'); -const {StyleSheet, Text, View} = ReactNative; +const {StyleSheet, Text, View, Alert} = ReactNative; exports.framework = 'React'; exports.title = 'Geolocation'; @@ -41,7 +41,7 @@ class GeolocationExample extends React.Component<{}, $FlowFixMeState> { const initialPosition = JSON.stringify(position); this.setState({initialPosition}); }, - error => alert(JSON.stringify(error)), + error => Alert.alert('Error', JSON.stringify(error)), {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}, ); this.watchID = navigator.geolocation.watchPosition(position => { diff --git a/RNTester/js/MultiColumnExample.js b/RNTester/js/MultiColumnExample.js index 1266cf1b6f771e..28f7804c5efa04 100644 --- a/RNTester/js/MultiColumnExample.js +++ b/RNTester/js/MultiColumnExample.js @@ -12,7 +12,7 @@ const React = require('react'); const ReactNative = require('react-native'); -const {FlatList, StyleSheet, Text, View} = ReactNative; +const {FlatList, StyleSheet, Text, View, Alert} = ReactNative; const RNTesterPage = require('./RNTesterPage'); @@ -91,7 +91,9 @@ class MultiColumnExample extends React.PureComponent< data={filteredData} key={this.state.numColumns + (this.state.fixedHeight ? 'f' : 'v')} numColumns={this.state.numColumns || 1} - onRefresh={() => alert('onRefresh: nothing to refresh :P')} + onRefresh={() => + Alert.alert('Alert', 'onRefresh: nothing to refresh :P') + } refreshing={false} renderItem={this._renderItemComponent} disableVirtualization={!this.state.virtualized} diff --git a/RNTester/js/TextInputExample.ios.js b/RNTester/js/TextInputExample.ios.js index 1240ba2d2893fa..762451952299f9 100644 --- a/RNTester/js/TextInputExample.ios.js +++ b/RNTester/js/TextInputExample.ios.js @@ -14,7 +14,7 @@ const Button = require('Button'); const InputAccessoryView = require('InputAccessoryView'); const React = require('react'); const ReactNative = require('react-native'); -const {Text, TextInput, View, StyleSheet, Slider, Switch} = ReactNative; +const {Text, TextInput, View, StyleSheet, Slider, Switch, Alert} = ReactNative; class WithLabel extends React.Component<$FlowFixMeProps> { render() { @@ -862,7 +862,9 @@ exports.examples = [ returnKeyType="next" blurOnSubmit={true} multiline={true} - onSubmitEditing={event => alert(event.nativeEvent.text)} + onSubmitEditing={event => + Alert.alert('Alert', event.nativeEvent.text) + } /> ); diff --git a/RNTester/js/TransparentHitTestExample.js b/RNTester/js/TransparentHitTestExample.js index 34fa7387cc25f2..908183bf56fdae 100644 --- a/RNTester/js/TransparentHitTestExample.js +++ b/RNTester/js/TransparentHitTestExample.js @@ -12,13 +12,13 @@ const React = require('react'); const ReactNative = require('react-native'); -const {Text, View, TouchableOpacity} = ReactNative; +const {Text, View, TouchableOpacity, Alert} = ReactNative; class TransparentHitTestExample extends React.Component<{}> { render() { return ( - alert('Hi!')}> + Alert.alert('Alert', 'Hi!')}> HELLO!