Skip to content

Commit ce41274

Browse files
iwoplazafacebook-github-bot
authored andcommitted
Migrated components to export syntax (part 2) (#48767)
Summary: Pull Request resolved: #48767 ## Motivation Modernising the react-native codebase to allow for ingestion by modern Flow tooling. ## This diff - Updates a handful of components in `Libraries/Components` to use `export` syntax - `export default` for qualified objects, many `export` statements for collections (determined by how it's imported) - Appends `.default` to requires of the changed files. - Updates test files. - Updates the public API snapshot (intented breaking change) Changelog: [General][Breaking] - Files inside `Libraries/Components` use `export` syntax, which requires the addition of `.default` when imported with the CJS `require` syntax. Reviewed By: yungsters Differential Revision: D68335872 fbshipit-source-id: eb0c67039edfe92e9e133726f6b01900dd2c2322
1 parent b200c7c commit ce41274

File tree

16 files changed

+39
-33
lines changed

16 files changed

+39
-33
lines changed

packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import * as React from 'react';
1919

2020
const PlatformActivityIndicator =
2121
Platform.OS === 'android'
22-
? require('../ProgressBarAndroid/ProgressBarAndroid')
22+
? require('../ProgressBarAndroid/ProgressBarAndroid').default
2323
: require('./ActivityIndicatorViewNativeComponent').default;
2424

2525
const GRAY = '#999999';

packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ const ProgressBarAndroidWithForwardedRef: component(
106106
);
107107
});
108108

109-
module.exports =
110-
/* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an
111-
* error found when Flow v0.89 was deployed. To see the error, delete this
112-
* comment and run Flow. */
113-
(ProgressBarAndroidWithForwardedRef: typeof ProgressBarAndroidNativeComponent);
109+
export default /* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an
110+
* error found when Flow v0.89 was deployed. To see the error, delete this
111+
* comment and run Flow. */
112+
(ProgressBarAndroidWithForwardedRef: typeof ProgressBarAndroidNativeComponent);

packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ import typeof ProgressBarAndroidNativeComponentType from './ProgressBarAndroidNa
1515

1616
export type {ProgressBarAndroidProps} from './ProgressBarAndroid.android';
1717

18-
module.exports = (require('../UnimplementedViews/UnimplementedView'):
18+
export default (require('../UnimplementedViews/UnimplementedView'):
1919
| UnimplementedViewType
2020
| ProgressBarAndroidNativeComponentType);

packages/react-native/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const ReactNativeTestTools = require('../../../Utilities/ReactNativeTestTools');
1616
* comment suppresses an error found when Flow v0.99 was deployed. To see the
1717
* error, delete this comment and run Flow. */
1818
// $FlowFixMe[missing-platform-support]
19-
const ProgressBarAndroid = require('../ProgressBarAndroid.android');
19+
const ProgressBarAndroid = require('../ProgressBarAndroid.android').default;
2020
const React = require('react');
2121

2222
describe('<ProgressBarAndroid />', () => {

packages/react-native/Libraries/Components/RefreshControl/RefreshControl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,4 @@ class RefreshControl extends React.Component<RefreshControlProps> {
201201
};
202202
}
203203

204-
module.exports = RefreshControl;
204+
export default RefreshControl;

packages/react-native/Libraries/Components/ScrollView/ScrollView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1913,5 +1913,5 @@ Wrapper.displayName = 'ScrollView';
19131913
// $FlowExpectedError[prop-missing]
19141914
Wrapper.Context = ScrollViewContext;
19151915

1916-
module.exports = ((Wrapper: $FlowFixMe): typeof Wrapper &
1916+
export default ((Wrapper: $FlowFixMe): typeof Wrapper &
19171917
ScrollViewComponentStatics);

packages/react-native/Libraries/Components/ScrollView/__tests__/ScrollView-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const {create, unmount, update} = require('../../../../jest/renderer');
1515
const Text = require('../../../Text/Text');
1616
const ReactNativeTestTools = require('../../../Utilities/ReactNativeTestTools');
1717
const View = require('../../View/View');
18-
const ScrollView = require('../ScrollView');
18+
const ScrollView = require('../ScrollView').default;
1919
const React = require('react');
2020

2121
describe('ScrollView', () => {

packages/react-native/Libraries/Components/ScrollView/processDecelerationRate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ function processDecelerationRate(
2727
return decelerationRate;
2828
}
2929

30-
module.exports = processDecelerationRate;
30+
export default processDecelerationRate;

packages/react-native/Libraries/Components/Sound/SoundManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ const SoundManager = {
1818
},
1919
};
2020

21-
module.exports = SoundManager;
21+
export default SoundManager;

packages/react-native/Libraries/Components/StatusBar/StatusBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,4 @@ class StatusBar extends React.Component<Props> {
493493
}
494494
}
495495

496-
module.exports = StatusBar;
496+
export default StatusBar;

0 commit comments

Comments
 (0)