mirror of
https://github.com/facebook/react-native.git
synced 2024-11-21 21:27:46 +00:00
ESM requireNativeComponent
Summary: Changelog: [General][Changed] - ESM requireNativeComponent Reviewed By: yungsters Differential Revision: D42200329 fbshipit-source-id: f1120f06362dc25e48551b3f2421bbda7b68c571
This commit is contained in:
parent
aa8e69b696
commit
0aece02cb0
@ -29,4 +29,4 @@ const requireNativeComponent = <T>(uiViewClassName: string): HostComponent<T> =>
|
||||
getNativeComponentAttributes(uiViewClassName),
|
||||
): any): HostComponent<T>);
|
||||
|
||||
module.exports = requireNativeComponent;
|
||||
export default requireNativeComponent;
|
||||
|
2
index.js
2
index.js
@ -387,7 +387,7 @@ module.exports = {
|
||||
get requireNativeComponent(): <T>(
|
||||
uiViewClassName: string,
|
||||
) => HostComponent<T> {
|
||||
return require('./Libraries/ReactNative/requireNativeComponent');
|
||||
return require('./Libraries/ReactNative/requireNativeComponent').default;
|
||||
},
|
||||
get RootTagContext(): RootTagContext {
|
||||
return require('./Libraries/ReactNative/RootTag').RootTagContext;
|
||||
|
@ -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++;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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(),
|
||||
};
|
||||
|
@ -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'
|
||||
`;
|
||||
|
@ -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';"
|
||||
`;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user