Skip to content

Commit da695f3

Browse files
iwoplazafacebook-github-bot
authored andcommitted
Migrated components to export syntax (part 4) (#48808)
Summary: Pull Request resolved: #48808 ## 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)* - Synchronizes `GoodwillVideoEditorCandidateImage.js` with www, as it was using `require`s that would result in invalid code after this Diff's changes. Added `ReactNativeImage` shim. 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: D68436611 fbshipit-source-id: 14f33e375e60429ea2340fb49ddf9dc6eb79594f
1 parent 56a6060 commit da695f3

File tree

14 files changed

+35
-26
lines changed

14 files changed

+35
-26
lines changed

packages/react-native/Libraries/Components/Touchable/BoundingDimensions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ BoundingDimensions.getPooledFromElement = function (
5050

5151
PooledClass.addPoolingTo(BoundingDimensions as $FlowFixMe, twoArgumentPooler);
5252

53-
module.exports = BoundingDimensions;
53+
export default BoundingDimensions;

packages/react-native/Libraries/Components/Touchable/PooledClass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ const PooledClass = {
130130
fourArgumentPooler: (fourArgumentPooler: Pooler),
131131
};
132132

133-
module.exports = PooledClass;
133+
export default PooledClass;

packages/react-native/Libraries/Components/Touchable/Position.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ Position.prototype.destructor = function () {
3737

3838
PooledClass.addPoolingTo(Position as $FlowFixMe, twoArgumentPooler);
3939

40-
module.exports = Position;
40+
export default Position;

packages/react-native/Libraries/Components/Touchable/TouchableBounce.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class TouchableBounce extends React.Component<Props, State> {
214214
}
215215
}
216216

217-
module.exports = (React.forwardRef((props, hostRef) => (
217+
export default (React.forwardRef((props, hostRef) => (
218218
<TouchableBounce {...props} hostRef={hostRef} />
219219
)): component(
220220
ref: React.RefSetter<mixed>,

packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,4 +390,4 @@ const Touchable: component(
390390

391391
Touchable.displayName = 'TouchableHighlight';
392392

393-
module.exports = Touchable;
393+
export default Touchable;

packages/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,4 @@ const getBackgroundProp =
363363

364364
TouchableNativeFeedback.displayName = 'TouchableNativeFeedback';
365365

366-
module.exports = TouchableNativeFeedback;
366+
export default TouchableNativeFeedback;

packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,4 @@ const Touchable: component(
336336

337337
Touchable.displayName = 'TouchableOpacity';
338338

339-
module.exports = Touchable;
339+
export default Touchable;

packages/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const PASSTHROUGH_PROPS = [
110110
'testID',
111111
];
112112

113-
module.exports = function TouchableWithoutFeedback(props: Props): React.Node {
113+
export default function TouchableWithoutFeedback(props: Props): React.Node {
114114
const {
115115
disabled,
116116
rejectResponderTermination,
@@ -231,4 +231,4 @@ module.exports = function TouchableWithoutFeedback(props: Props): React.Node {
231231

232232
// $FlowFixMe[incompatible-call]
233233
return React.cloneElement(element, elementProps, ...children);
234-
};
234+
}

packages/react-native/Libraries/Components/Touchable/__tests__/TouchableOpacity-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
const {create} = require('../../../../jest/renderer');
1414
const Text = require('../../../Text/Text');
15-
const TouchableOpacity = require('../TouchableOpacity');
15+
const TouchableOpacity = require('../TouchableOpacity').default;
1616
const React = require('react');
1717

1818
describe('TouchableOpacity', () => {

packages/react-native/Libraries/Inspector/ElementProperties.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
1515

1616
import React from 'react';
1717

18-
const TouchableHighlight = require('../Components/Touchable/TouchableHighlight');
19-
const TouchableWithoutFeedback = require('../Components/Touchable/TouchableWithoutFeedback');
18+
const TouchableHighlight =
19+
require('../Components/Touchable/TouchableHighlight').default;
20+
const TouchableWithoutFeedback =
21+
require('../Components/Touchable/TouchableWithoutFeedback').default;
2022
const View = require('../Components/View/View');
2123
const flattenStyle = require('../StyleSheet/flattenStyle');
2224
const StyleSheet = require('../StyleSheet/StyleSheet');

0 commit comments

Comments
 (0)