Skip to content

Commit

Permalink
Rewrite imports in RNTester to use standard paths (#24317)
Browse files Browse the repository at this point in the history
Summary:
See #24316 for the motivation. This commit rewrites the imports in the RNTester project.

[General] [Changed] - Replaced Haste-style imports with standard path-style imports for RNTester
Pull Request resolved: #24317

Differential Revision: D14870504

Pulled By: cpojer

fbshipit-source-id: b14f22e7ce559efc332ced032617ca581196d90f
  • Loading branch information
ide authored and facebook-github-bot committed Apr 10, 2019
1 parent 265ae58 commit 26cce3d
Show file tree
Hide file tree
Showing 103 changed files with 339 additions and 302 deletions.
4 changes: 2 additions & 2 deletions RNTester/NativeModuleExample/NativeScreenshotManager.js
Expand Up @@ -10,8 +10,8 @@

'use strict';

import type {TurboModule} from 'RCTExport';
import * as TurboModuleRegistry from 'TurboModuleRegistry';
import type {TurboModule} from '../../Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from '../../Libraries/TurboModule/TurboModuleRegistry';

export interface Spec extends TurboModule {
+getConstants: () => {||};
Expand Down
10 changes: 5 additions & 5 deletions RNTester/RCTTest/RCTSnapshotNativeComponent.js
Expand Up @@ -10,9 +10,11 @@

'use strict';

import type {SyntheticEvent} from 'CoreEventTypes';
import type {ViewProps} from 'ViewPropTypes';
import type {NativeComponent} from 'ReactNative';
const {requireNativeComponent} = require('react-native');

import type {SyntheticEvent} from '../../Libraries/Types/CoreEventTypes';
import type {ViewProps} from '../../Libraries/Components/View/ViewPropTypes';
import type {NativeComponent} from '../../Libraries/Renderer/shims/ReactNative';

type SnapshotReadyEvent = SyntheticEvent<
$ReadOnly<{
Expand All @@ -28,8 +30,6 @@ type NativeProps = $ReadOnly<{|

type SnapshotViewNativeType = Class<NativeComponent<NativeProps>>;

const requireNativeComponent = require('requireNativeComponent');

module.exports = ((requireNativeComponent(
'RCTSnapshot',
): any): SnapshotViewNativeType);
3 changes: 1 addition & 2 deletions RNTester/js/ARTExample.js
Expand Up @@ -11,8 +11,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {ART, Platform, View} = ReactNative;
const {ART, Platform, View} = require('react-native');

const {Surface, Path, Group, Shape} = ART;

Expand Down
5 changes: 1 addition & 4 deletions RNTester/js/AccessibilityAndroidExample.android.js
Expand Up @@ -10,15 +10,12 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {
AccessibilityInfo,
StyleSheet,
Text,
View,
ToastAndroid,
TouchableWithoutFeedback,
} = ReactNative;
} = require('react-native');

const RNTesterBlock = require('./RNTesterBlock');
const RNTesterPage = require('./RNTesterPage');
Expand Down
9 changes: 7 additions & 2 deletions RNTester/js/AccessibilityExample.js
Expand Up @@ -10,8 +10,13 @@
'use strict';

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

const RNTesterBlock = require('./RNTesterBlock');

Expand Down
7 changes: 4 additions & 3 deletions RNTester/js/AccessibilityIOSExample.js
Expand Up @@ -11,8 +11,7 @@
'use strict';

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

const RNTesterBlock = require('./RNTesterBlock');

Expand All @@ -34,7 +33,9 @@ class AccessibilityIOSExample extends React.Component<Props> {
<Text>Accessibility magic tap example</Text>
</View>
<View
onAccessibilityEscape={() => alert('onAccessibilityEscape success')}
onAccessibilityEscape={() =>
Alert.alert('onAccessibilityEscape success')
}
accessible={true}>
<Text>Accessibility escape example</Text>
</View>
Expand Down
8 changes: 4 additions & 4 deletions RNTester/js/ActionSheetIOSExample.js
Expand Up @@ -11,15 +11,15 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {
ActionSheetIOS,
StyleSheet,
Text,
View,
Alert,
NativeModules,
} = ReactNative;
findNodeHandle,
} = require('react-native');
const ScreenshotManager = NativeModules.ScreenshotManager;

const BUTTONS = ['Option 0', 'Option 1', 'Option 2', 'Delete', 'Cancel'];
Expand Down Expand Up @@ -128,7 +128,7 @@ class ActionSheetAnchorExample extends React.Component<
cancelButtonIndex: CANCEL_INDEX,
destructiveButtonIndex: DESTRUCTIVE_INDEX,
anchor: this.anchorRef.current
? ReactNative.findNodeHandle(this.anchorRef.current)
? findNodeHandle(this.anchorRef.current)
: undefined,
},
buttonIndex => {
Expand Down Expand Up @@ -263,7 +263,7 @@ class ShareScreenshotAnchorExample extends React.Component<
url: uri,
excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'],
anchor: this.anchorRef.current
? ReactNative.findNodeHandle(this.anchorRef.current)
? findNodeHandle(this.anchorRef.current)
: undefined,
},
error => Alert.alert('Error', error),
Expand Down
9 changes: 7 additions & 2 deletions RNTester/js/AlertExample.js
Expand Up @@ -10,8 +10,13 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Alert, StyleSheet, Text, TouchableHighlight, View} = ReactNative;
const {
Alert,
StyleSheet,
Text,
TouchableHighlight,
View,
} = require('react-native');

const RNTesterBlock = require('./RNTesterBlock');

Expand Down
9 changes: 7 additions & 2 deletions RNTester/js/AlertIOSExample.js
Expand Up @@ -11,8 +11,13 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {StyleSheet, View, Text, TouchableHighlight, Alert} = ReactNative;
const {
StyleSheet,
View,
Text,
TouchableHighlight,
Alert,
} = require('react-native');

const {SimpleAlertExampleBlock} = require('./AlertExample');

Expand Down
3 changes: 1 addition & 2 deletions RNTester/js/AnimatedExample.js
Expand Up @@ -11,8 +11,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Animated, Easing, StyleSheet, Text, View} = ReactNative;
const {Animated, Easing, StyleSheet, Text, View} = require('react-native');
const RNTesterButton = require('./RNTesterButton');

const styles = StyleSheet.create({
Expand Down
11 changes: 8 additions & 3 deletions RNTester/js/AnimatedGratuitousApp/AnExApp.js
Expand Up @@ -11,10 +11,15 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Animated, LayoutAnimation, PanResponder, StyleSheet, View} = ReactNative;
const {
Animated,
LayoutAnimation,
PanResponder,
StyleSheet,
View,
} = require('react-native');

const AnExSet = require('AnExSet');
const AnExSet = require('./AnExSet');

const CIRCLE_SIZE = 80;
const CIRCLE_MARGIN = 18;
Expand Down
3 changes: 1 addition & 2 deletions RNTester/js/AnimatedGratuitousApp/AnExBobble.js
Expand Up @@ -11,8 +11,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Animated, PanResponder, StyleSheet, View} = ReactNative;
const {Animated, PanResponder, StyleSheet, View} = require('react-native');

const NUM_BOBBLES = 5;
const RAD_EACH = Math.PI / 2 / (NUM_BOBBLES - 2);
Expand Down
3 changes: 1 addition & 2 deletions RNTester/js/AnimatedGratuitousApp/AnExChained.js
Expand Up @@ -11,8 +11,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Animated, PanResponder, StyleSheet, View} = ReactNative;
const {Animated, PanResponder, StyleSheet, View} = require('react-native');

class AnExChained extends React.Component<Object, any> {
constructor(props: Object) {
Expand Down
10 changes: 8 additions & 2 deletions RNTester/js/AnimatedGratuitousApp/AnExScroll.js
Expand Up @@ -11,8 +11,14 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Animated, Image, ScrollView, StyleSheet, Text, View} = ReactNative;
const {
Animated,
Image,
ScrollView,
StyleSheet,
Text,
View,
} = require('react-native');

class AnExScroll extends React.Component<$FlowFixMeProps, any> {
state: any = {scrollX: new Animated.Value(0)};
Expand Down
9 changes: 7 additions & 2 deletions RNTester/js/AnimatedGratuitousApp/AnExSet.js
Expand Up @@ -11,8 +11,13 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Animated, PanResponder, StyleSheet, Text, View} = ReactNative;
const {
Animated,
PanResponder,
StyleSheet,
Text,
View,
} = require('react-native');

const AnExBobble = require('./AnExBobble');
const AnExChained = require('./AnExChained');
Expand Down
3 changes: 1 addition & 2 deletions RNTester/js/AnimatedGratuitousApp/AnExTilt.js
Expand Up @@ -11,8 +11,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Animated, PanResponder, StyleSheet} = ReactNative;
const {Animated, PanResponder, StyleSheet} = require('react-native');

class AnExTilt extends React.Component<Object, any> {
constructor(props: Object) {
Expand Down
3 changes: 1 addition & 2 deletions RNTester/js/AppStateExample.js
Expand Up @@ -11,8 +11,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {AppState, Text, View} = ReactNative;
const {AppState, Text, View} = require('react-native');

class AppStateSubscription extends React.Component<
$FlowFixMeProps,
Expand Down
5 changes: 2 additions & 3 deletions RNTester/js/AssetScaledImageExample.js
Expand Up @@ -11,10 +11,9 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Image, StyleSheet, View, ScrollView} = ReactNative;
const {Image, StyleSheet, View, ScrollView} = require('react-native');

import type {PhotoIdentifier} from 'CameraRoll';
import type {PhotoIdentifier} from '../../Libraries/CameraRoll/CameraRoll';

type Props = $ReadOnly<{|
asset: PhotoIdentifier,
Expand Down
3 changes: 1 addition & 2 deletions RNTester/js/AsyncStorageExample.js
Expand Up @@ -11,8 +11,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {AsyncStorage, PickerIOS, Text, View} = ReactNative;
const {AsyncStorage, PickerIOS, Text, View} = require('react-native');
const PickerItemIOS = PickerIOS.Item;

const STORAGE_KEY = '@AsyncStorageExample:key';
Expand Down
3 changes: 1 addition & 2 deletions RNTester/js/BorderExample.js
Expand Up @@ -10,8 +10,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {StyleSheet, View} = ReactNative;
const {StyleSheet, View} = require('react-native');

const styles = StyleSheet.create({
box: {
Expand Down
3 changes: 1 addition & 2 deletions RNTester/js/BoxShadowExample.js
Expand Up @@ -10,8 +10,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Image, StyleSheet, View} = ReactNative;
const {Image, StyleSheet, View} = require('react-native');

const styles = StyleSheet.create({
box: {
Expand Down
3 changes: 1 addition & 2 deletions RNTester/js/ButtonExample.js
Expand Up @@ -11,8 +11,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Alert, Button, View, StyleSheet} = ReactNative;
const {Alert, Button, View, StyleSheet} = require('react-native');

function onButtonPress(buttonName) {
Alert.alert(`${buttonName} has been pressed!`);
Expand Down
8 changes: 5 additions & 3 deletions RNTester/js/CameraRollExample.js
Expand Up @@ -10,7 +10,6 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {
CameraRoll,
Image,
Expand All @@ -20,15 +19,18 @@ const {
Text,
View,
TouchableOpacity,
} = ReactNative;
} = require('react-native');

const invariant = require('invariant');

const CameraRollView = require('./CameraRollView');

const AssetScaledImageExampleView = require('./AssetScaledImageExample');

import type {PhotoIdentifier, GroupTypes} from 'CameraRoll';
import type {
PhotoIdentifier,
GroupTypes,
} from '../../Libraries/CameraRoll/CameraRoll';

type Props = $ReadOnly<{|
navigator?: ?Array<
Expand Down
9 changes: 4 additions & 5 deletions RNTester/js/CameraRollView.js
Expand Up @@ -11,7 +11,6 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {
ActivityIndicator,
Alert,
Expand All @@ -22,16 +21,16 @@ const {
Platform,
StyleSheet,
View,
} = ReactNative;
} = require('react-native');

const groupByEveryN = require('groupByEveryN');
const logError = require('logError');
const groupByEveryN = require('../../Libraries/Utilities/groupByEveryN');
const logError = require('../../Libraries/Utilities/logError');

import type {
PhotoIdentifier,
PhotoIdentifiersPage,
GetPhotosParams,
} from 'CameraRoll';
} from '../../Libraries/CameraRoll/CameraRoll';

type Props = $ReadOnly<{|
/**
Expand Down
3 changes: 1 addition & 2 deletions RNTester/js/CheckBoxExample.js
Expand Up @@ -11,8 +11,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {CheckBox, Text, View, StyleSheet} = ReactNative;
const {CheckBox, Text, View, StyleSheet} = require('react-native');

type BasicState = {|
trueCheckBoxIsOn: boolean,
Expand Down
3 changes: 1 addition & 2 deletions RNTester/js/ClipboardExample.js
Expand Up @@ -11,8 +11,7 @@
'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Clipboard, View, Text, StyleSheet} = ReactNative;
const {Clipboard, View, Text, StyleSheet} = require('react-native');

type Props = $ReadOnly<{||}>;
type State = {|
Expand Down

0 comments on commit 26cce3d

Please sign in to comment.