Skip to content

Commit

Permalink
Fix up this pattern var React = require('react-native');
Browse files Browse the repository at this point in the history
Summary:First I searched for special cases that destructor PropTypes:

```
(?s)React\s*=\s*require\('react\-native'\).*(Children|PropTypes)[^\{\}]*\}\s*=\s*React;
```

I split them up manually.

Then I replaced the React = require('react-native') + destructuring pattern...

```
(?s)(const|var)\s+React\s*=\s*require\('react\-native'\)(.*[^\{\}]*\}\s*=\s*)React;
```

...with...

```
$1 React = require('react');
$1 ReactNative = require('react-native')$2ReactNative;
```

I used lint to figure out if I left some unnecessary imports.

Finally I grepped for just

```
React\s*=\s*require\('react\-native'\)
```

to catch any remaining patterns.

Also, `} = React.NativeModules` -> `} = ReactNative.NativeModules`.

Reviewed By: spicyj

Differential Revision: D3158991

fb-gh-sync-id: f97e8e921e193d6ea1a49d8d1bf3f09be7bed5c3
fbshipit-source-id: f97e8e921e193d6ea1a49d8d1bf3f09be7bed5c3
  • Loading branch information
sebmarkbage authored and Facebook Github Bot 0 committed Apr 9, 2016
1 parent 58db9f3 commit a80dd9a
Show file tree
Hide file tree
Showing 138 changed files with 414 additions and 283 deletions.
5 changes: 3 additions & 2 deletions Examples/2048/Game2048.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
*/
'use strict';

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

var Animated = require('Animated');
var GameBoard = require('GameBoard');
Expand Down
5 changes: 3 additions & 2 deletions Examples/Movies/MovieCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
'use strict';

var React = require('react-native');
var React = require('react');
var ReactNative = require('react-native');
var {
Image,
Platform,
Expand All @@ -24,7 +25,7 @@ var {
TouchableHighlight,
TouchableNativeFeedback,
View
} = React;
} = ReactNative;

var getStyleFromScore = require('./getStyleFromScore');
var getImageSource = require('./getImageSource');
Expand Down
5 changes: 3 additions & 2 deletions Examples/Movies/MovieScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*/
'use strict';

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

var getImageSource = require('./getImageSource');
var getStyleFromScore = require('./getStyleFromScore');
Expand Down
5 changes: 3 additions & 2 deletions Examples/Movies/MoviesApp.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
*/
'use strict';

var React = require('react-native');
var React = require('react');
var ReactNative = require('react-native');
var {
AppRegistry,
BackAndroid,
Navigator,
StyleSheet,
ToolbarAndroid,
View,
} = React;
} = ReactNative;

var MovieScreen = require('./MovieScreen');
var SearchScreen = require('./SearchScreen');
Expand Down
5 changes: 3 additions & 2 deletions Examples/Movies/MoviesApp.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
*/
'use strict';

var React = require('react-native');
var React = require('react');
var ReactNative = require('react-native');
var {
AppRegistry,
NavigatorIOS,
StyleSheet,
} = React;
} = ReactNative;

var SearchScreen = require('./SearchScreen');

Expand Down
5 changes: 3 additions & 2 deletions Examples/Movies/SearchBar.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/
'use strict';

var React = require('react-native');
var React = require('react');
var ReactNative = require('react-native');
var {
Image,
Platform,
Expand All @@ -25,7 +26,7 @@ var {
StyleSheet,
TouchableNativeFeedback,
View,
} = React;
} = ReactNative;

var IS_RIPPLE_EFFECT_SUPPORTED = Platform.Version >= 21;

Expand Down
5 changes: 3 additions & 2 deletions Examples/Movies/SearchBar.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
*/
'use strict';

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

var SearchBar = React.createClass({
render: function() {
Expand Down
5 changes: 3 additions & 2 deletions Examples/Movies/SearchScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
'use strict';

var React = require('react-native');
var React = require('react');
var ReactNative = require('react-native');
var {
ActivityIndicatorIOS,
ListView,
Expand All @@ -24,7 +25,7 @@ var {
StyleSheet,
Text,
View,
} = React;
} = ReactNative;
var TimerMixin = require('react-timer-mixin');

var invariant = require('fbjs/lib/invariant');
Expand Down
4 changes: 2 additions & 2 deletions Examples/Movies/getStyleFromScore.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
'use strict';

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

var MAX_VALUE = 200;

Expand Down
5 changes: 3 additions & 2 deletions Examples/TicTacToe/TicTacToeApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
*/
'use strict';

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

class Board {
grid: Array<Array<number>>;
Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/AccessibilityAndroidExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
*/
'use strict';

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

var UIExplorerBlock = require('./UIExplorerBlock');
var UIExplorerPage = require('./UIExplorerPage');
Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/AccessibilityIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
*/
'use strict';

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

var AccessibilityIOSExample = React.createClass({
render() {
Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/ActionSheetIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*/
'use strict';

var React = require('react-native');
var React = require('react');
var ReactNative = require('react-native');
var {
ActionSheetIOS,
StyleSheet,
Text,
UIManager,
View,
} = React;
} = ReactNative;

var BUTTONS = [
'Option 0',
Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/ActivityIndicatorIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
*/
'use strict';

var React = require('react-native');
var React = require('react');
var ReactNative = require('react-native');
var {
ActivityIndicatorIOS,
StyleSheet,
View,
} = React;
} = ReactNative;
var TimerMixin = require('react-timer-mixin');

var ToggleAnimatingActivityIndicator = React.createClass({
Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/AdSupportIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
*/
'use strict';

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

exports.framework = 'React';
exports.title = 'Advertising ID';
Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/AlertExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

'use strict';

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

var UIExplorerBlock = require('./UIExplorerBlock');

Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/AlertIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*/
'use strict';

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

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

Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/AnimatedExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*/
'use strict';

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

exports.framework = 'React';
Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/AnimatedGratuitousApp/AnExApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
*/
'use strict';

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

var AnExSet = require('AnExSet');

Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/AnimatedGratuitousApp/AnExBobble.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
*/
'use strict';

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

var NUM_BOBBLES = 5;
var RAD_EACH = Math.PI / 2 / (NUM_BOBBLES - 2);
Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/AnimatedGratuitousApp/AnExChained.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
*/
'use strict';

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

class AnExChained extends React.Component {
state: any;
Expand Down
5 changes: 3 additions & 2 deletions Examples/UIExplorer/AnimatedGratuitousApp/AnExScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
*/
'use strict';

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

class AnExScroll extends React.Component {
state: any = { scrollX: new Animated.Value(0) };
Expand Down
Loading

0 comments on commit a80dd9a

Please sign in to comment.