Skip to content

Commit 9eeef22

Browse files
iwoplazafacebook-github-bot
authored andcommitted
Migrated components to export syntax (part 1) (#48765)
Summary: Pull Request resolved: #48765 ## 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: cortinico Differential Revision: D68330077 fbshipit-source-id: 6bf00c82f72dbcaaa26470d7ea0917639fc3de4a
1 parent 379242e commit 9eeef22

File tree

13 files changed

+24
-20
lines changed

13 files changed

+24
-20
lines changed

packages/react-native/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.android.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ function legacySendAccessibilityEvent(
3333
}
3434
}
3535

36-
module.exports = legacySendAccessibilityEvent;
36+
export default legacySendAccessibilityEvent;

packages/react-native/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ function legacySendAccessibilityEvent(
2323
}
2424
}
2525

26-
module.exports = legacySendAccessibilityEvent;
26+
export default legacySendAccessibilityEvent;

packages/react-native/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ declare function legacySendAccessibilityEvent(
1717
eventType: string,
1818
): void;
1919

20-
module.exports = legacySendAccessibilityEvent;
20+
export default legacySendAccessibilityEvent;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import NativeClipboard from './NativeClipboard';
1313
/**
1414
* `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
1515
*/
16-
module.exports = {
16+
export default {
1717
/**
1818
* Get content of string type, this method returns a `Promise`, so you can use following code to get clipboard content
1919
* ```javascript

packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,4 +391,4 @@ const styles = StyleSheet.create({
391391
},
392392
});
393393

394-
module.exports = DrawerLayoutAndroid;
394+
export default DrawerLayoutAndroid;

packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212

1313
import typeof DrawerLayoutAndroid from './DrawerLayoutAndroid.android';
1414

15-
module.exports =
16-
require('../UnimplementedViews/UnimplementedView') as $FlowFixMe as DrawerLayoutAndroid;
15+
export default require('../UnimplementedViews/UnimplementedView') as $FlowFixMe as DrawerLayoutAndroid;

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

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

2323
describe('<DrawerLayoutAndroid />', () => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,4 @@ class Keyboard {
202202
}
203203
}
204204

205-
module.exports = (new Keyboard(): Keyboard);
205+
export default (new Keyboard(): Keyboard);

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

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

1212
const LayoutAnimation = require('../../../LayoutAnimation/LayoutAnimation');
1313
const dismissKeyboard = require('../../../Utilities/dismissKeyboard');
14-
const Keyboard = require('../Keyboard');
14+
const Keyboard = require('../Keyboard').default;
1515

1616
jest.mock('../../../LayoutAnimation/LayoutAnimation');
1717
jest.mock('../../../Utilities/dismissKeyboard');

packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ module.exports = {
7777
return require('../Core/ReactFiberErrorDialog').default;
7878
},
7979
get legacySendAccessibilityEvent(): legacySendAccessibilityEvent {
80-
return require('../Components/AccessibilityInfo/legacySendAccessibilityEvent');
80+
return require('../Components/AccessibilityInfo/legacySendAccessibilityEvent')
81+
.default;
8182
},
8283
get RawEventEmitter(): RawEventEmitter {
8384
return require('../Core/RawEventEmitter').default;

0 commit comments

Comments
 (0)