diff --git a/Libraries/ReactNative/requireNativeComponent.js b/Libraries/ReactNative/requireNativeComponent.js index c17d9895a76..e9be731df0a 100644 --- a/Libraries/ReactNative/requireNativeComponent.js +++ b/Libraries/ReactNative/requireNativeComponent.js @@ -29,4 +29,4 @@ const requireNativeComponent = (uiViewClassName: string): HostComponent => getNativeComponentAttributes(uiViewClassName), ): any): HostComponent); -module.exports = requireNativeComponent; +export default requireNativeComponent; diff --git a/index.js b/index.js index ec3532ac129..80ee3be4e51 100644 --- a/index.js +++ b/index.js @@ -387,7 +387,7 @@ module.exports = { get requireNativeComponent(): ( uiViewClassName: string, ) => HostComponent { - return require('./Libraries/ReactNative/requireNativeComponent'); + return require('./Libraries/ReactNative/requireNativeComponent').default; }, get RootTagContext(): RootTagContext { return require('./Libraries/ReactNative/RootTag').RootTagContext; diff --git a/jest/mockNativeComponent.js b/jest/mockNativeComponent.js index c42baec2be2..da1cf85e202 100644 --- a/jest/mockNativeComponent.js +++ b/jest/mockNativeComponent.js @@ -13,7 +13,7 @@ const React = require('react'); let nativeTag = 1; -module.exports = viewName => { +export default viewName => { const Component = class extends React.Component { _nativeTag = nativeTag++; diff --git a/jest/mockScrollView.js b/jest/mockScrollView.js index ceeb1843bbd..59c7cec3392 100644 --- a/jest/mockScrollView.js +++ b/jest/mockScrollView.js @@ -15,7 +15,7 @@ const React = require('react'); const View = require('../Libraries/Components/View/View'); -const requireNativeComponent = require('../Libraries/ReactNative/requireNativeComponent'); +import requireNativeComponent from '../Libraries/ReactNative/requireNativeComponent'; const RCTScrollView: $FlowFixMe = requireNativeComponent('RCTScrollView'); function mockScrollView(BaseComponent: $FlowFixMe) { diff --git a/jest/setup.js b/jest/setup.js index 511c6642a46..93745e789ad 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -338,10 +338,10 @@ jest .mock('../Libraries/NativeComponent/NativeComponentRegistry', () => { return { get: jest.fn((name, viewConfigProvider) => { - return jest.requireActual('./mockNativeComponent')(name); + return jest.requireActual('./mockNativeComponent').default(name); }), getWithFallback_DEPRECATED: jest.fn((name, viewConfigProvider) => { - return jest.requireActual('./mockNativeComponent')(name); + return jest.requireActual('./mockNativeComponent').default(name); }), setRuntimeConfigProvider: jest.fn(), }; diff --git a/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js b/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js index a55b940eabc..61992d8aa33 100644 --- a/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js +++ b/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js @@ -10,7 +10,7 @@ 'use strict'; const NOT_A_NATIVE_COMPONENT = ` -const requireNativeComponent = require('requireNativeComponent'); +import requireNativeComponent from 'requireNativeComponent'; export default 'Not a view config' `; diff --git a/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap b/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap index 5aecf0862f1..68440b3f72b 100644 --- a/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap +++ b/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap @@ -127,7 +127,7 @@ export const Commands = { `; exports[`Babel plugin inline view configs can inline config for NotANativeComponent.js 1`] = ` -"const requireNativeComponent = require('requireNativeComponent'); +"import requireNativeComponent from 'requireNativeComponent'; export default 'Not a view config';" `;