Skip to content

Commit 8293e4c

Browse files
elicwhitefacebook-github-bot
authored andcommitted
Remove ReactNative.NativeComponent from React Native
Summary: This class is no longer used by the core and thus can be removed. It isn't exposed as part of our public API so this is technically not a breaking change, although it may still cause people trouble if they are reaching into internals. It is expected that people will use forwardRef instead of this class. I will follow up this diff with a removal from the ReactNativeRenderer as well. Changelog: [Internal] Remove ReactNative.NativeComponent from React Native Reviewed By: JoshuaGross Differential Revision: D19888400 fbshipit-source-id: 78da51e6c0edf9d8706395d376c3bfe75dabda03
1 parent 2b5283e commit 8293e4c

File tree

6 files changed

+17
-41
lines changed

6 files changed

+17
-41
lines changed

Libraries/Components/ScrollResponder.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,7 @@ const ScrollResponderMixin = {
570570
* down to make it meet the keyboard's top. Default is false.
571571
*/
572572
scrollResponderScrollNativeHandleToKeyboard: function<T>(
573-
nodeHandle:
574-
| number
575-
| React.ElementRef<HostComponent<T>>
576-
| React.ElementRef<Class<ReactNative.NativeComponent<T>>>,
573+
nodeHandle: number | React.ElementRef<HostComponent<T>>,
577574
additionalOffset?: number,
578575
preventNegativeScrollOffset?: boolean,
579576
) {

Libraries/__flowtests__/ReactNativeTypes-flowtest.js

+2-22
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111
'use strict';
1212

1313
import * as React from 'react';
14-
import type {
15-
HostComponent,
16-
_InternalReactNativeComponentClass,
17-
} from '../Renderer/shims/ReactNativeTypes';
14+
import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
1815

1916
function takesHostComponentInstance(
20-
instance: React$ElementRef<HostComponent<mixed>> | null,
17+
instance: React.ElementRef<HostComponent<mixed>> | null,
2118
): void {}
2219

2320
const MyHostComponent = (('Host': any): HostComponent<mixed>);
@@ -33,20 +30,3 @@ const MyHostComponent = (('Host': any): HostComponent<mixed>);
3330
hostComponentRef.measureLayout(hostComponentRef, () => {});
3431
}}
3532
/>;
36-
37-
declare var NativeComponent: _InternalReactNativeComponentClass<{...}>;
38-
class MyNativeComponent extends NativeComponent {}
39-
40-
<MyNativeComponent
41-
ref={nativeComponentRef => {
42-
// $FlowExpectedError - NativeComponent cannot be passed as HostComponent.
43-
takesHostComponentInstance(nativeComponentRef);
44-
45-
if (nativeComponentRef == null) {
46-
return;
47-
}
48-
49-
// $FlowExpectedError - NativeComponent cannot be passed as HostComponent.
50-
nativeComponentRef.measureLayout(nativeComponentRef, () => {});
51-
}}
52-
/>;

jest/setup.js

-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ jest
150150
.NativeMethodsMixin;
151151

152152
Object.assign(NativeMethodsMixin, MockNativeMethods);
153-
Object.assign(ReactNative.NativeComponent.prototype, MockNativeMethods);
154153

155154
return ReactNative;
156155
})

packages/babel-plugin-inline-view-configs/__test_fixtures__/failures.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ const COMMANDS_EXPORTED_WITH_DIFFERENT_NAME = `
1616
const codegenNativeComponent = require('codegenNativeComponent');
1717
1818
import type {ViewProps} from 'ViewPropTypes';
19-
import type {NativeComponent} from 'codegenNativeComponent';
19+
import type {NativeComponentType} from 'codegenNativeComponent';
2020
2121
type ModuleProps = $ReadOnly<{|
2222
...ViewProps,
2323
|}>;
2424
25-
type NativeType = NativeComponent<ModuleProps>;
25+
type NativeType = NativeComponentType<ModuleProps>;
2626
2727
interface NativeCommands {
2828
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>) => void;
@@ -39,13 +39,13 @@ const OTHER_COMMANDS_EXPORT = `
3939
const codegenNativeComponent = require('codegenNativeComponent');
4040
4141
import type {ViewProps} from 'ViewPropTypes';
42-
import type {NativeComponent} from 'codegenNativeComponent';
42+
import type {NativeComponentType} from 'codegenNativeComponent';
4343
4444
type ModuleProps = $ReadOnly<{|
4545
...ViewProps,
4646
|}>;
4747
48-
type NativeType = NativeComponent<ModuleProps>;
48+
type NativeType = NativeComponentType<ModuleProps>;
4949
5050
interface NativeCommands {
5151
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>) => void;
@@ -60,15 +60,15 @@ const COMMANDS_EXPORTED_WITH_SHORTHAND = `
6060
// @flow
6161
6262
const codegenNativeComponent = require('codegenNativeComponent');
63-
import type {NativeComponent} from 'codegenNativeComponent';
63+
import type {NativeComponentType} from 'codegenNativeComponent';
6464
6565
import type {ViewProps} from 'ViewPropTypes';
6666
6767
type ModuleProps = $ReadOnly<{|
6868
...ViewProps,
6969
|}>;
7070
71-
type NativeType = NativeComponent<ModuleProps>;
71+
type NativeType = NativeComponentType<ModuleProps>;
7272
7373
interface NativeCommands {
7474
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>) => void;

packages/babel-plugin-inline-view-configs/__test_fixtures__/fixtures.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import type {
2727
DirectEventHandler,
2828
WithDefault,
2929
} from 'CodegenFlowtypes';
30-
import type {NativeComponent} from 'codegenNativeComponent';
30+
import type {NativeComponentType} from 'codegenNativeComponent';
3131
3232
import type {ViewProps} from 'ViewPropTypes';
3333
@@ -42,7 +42,7 @@ type ModuleProps = $ReadOnly<{|
4242
onBubblingEventDefinedInlineNull: BubblingEventHandler<null>,
4343
|}>;
4444
45-
type NativeType = NativeComponent<ModuleProps>;
45+
type NativeType = NativeComponentType<ModuleProps>;
4646
4747
interface NativeCommands {
4848
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void;
@@ -64,7 +64,7 @@ const FULL_NATIVE_COMPONENT_WITH_TYPE_EXPORT = `
6464
6565
const codegenNativeCommands = require('codegenNativeCommands');
6666
const codegenNativeComponent = require('codegenNativeComponent');
67-
import type {NativeComponent} from 'codegenNativeComponent';
67+
import type {NativeComponentType} from 'codegenNativeComponent';
6868
6969
import type {
7070
Int32,
@@ -86,7 +86,7 @@ type ModuleProps = $ReadOnly<{|
8686
onBubblingEventDefinedInlineNull: BubblingEventHandler<null>,
8787
|}>;
8888
89-
type NativeType = NativeComponent<ModuleProps>;
89+
type NativeType = NativeComponentType<ModuleProps>;
9090
9191
interface NativeCommands {
9292
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void;

packages/babel-plugin-inline-view-configs/__tests__/__snapshots__/index-test.js.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const codegenNativeCommands = require('codegenNativeCommands');
77
const codegenNativeComponent = require('codegenNativeComponent');
88
99
import type { Int32, BubblingEventHandler, DirectEventHandler, WithDefault } from 'CodegenFlowtypes';
10-
import type { NativeComponent } from 'codegenNativeComponent';
10+
import type { NativeComponentType } from 'codegenNativeComponent';
1111
import type { ViewProps } from 'ViewPropTypes';
1212
type ModuleProps = $ReadOnly<{| ...ViewProps,
1313
// Props
@@ -16,7 +16,7 @@ type ModuleProps = $ReadOnly<{| ...ViewProps,
1616
onDirectEventDefinedInlineNull: DirectEventHandler<null>,
1717
onBubblingEventDefinedInlineNull: BubblingEventHandler<null>,
1818
|}>;
19-
type NativeType = NativeComponent<ModuleProps>;
19+
type NativeType = NativeComponentType<ModuleProps>;
2020
interface NativeCommands {
2121
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void,
2222
+scrollTo: (viewRef: React.ElementRef<NativeType>, y: Int32, animated: boolean) => void,
@@ -71,7 +71,7 @@ const codegenNativeCommands = require('codegenNativeCommands');
7171
7272
const codegenNativeComponent = require('codegenNativeComponent');
7373
74-
import type { NativeComponent } from 'codegenNativeComponent';
74+
import type { NativeComponentType } from 'codegenNativeComponent';
7575
import type { Int32, BubblingEventHandler, DirectEventHandler, WithDefault } from 'CodegenFlowtypes';
7676
import type { ViewProps } from 'ViewPropTypes';
7777
type ModuleProps = $ReadOnly<{| ...ViewProps,
@@ -81,7 +81,7 @@ type ModuleProps = $ReadOnly<{| ...ViewProps,
8181
onDirectEventDefinedInlineNull: DirectEventHandler<null>,
8282
onBubblingEventDefinedInlineNull: BubblingEventHandler<null>,
8383
|}>;
84-
type NativeType = NativeComponent<ModuleProps>;
84+
type NativeType = NativeComponentType<ModuleProps>;
8585
interface NativeCommands {
8686
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void,
8787
+scrollTo: (viewRef: React.ElementRef<NativeType>, y: Int32, animated: boolean) => void,

0 commit comments

Comments
 (0)