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
This commit is contained in:
Eli White
2020-02-13 15:08:27 -08:00
committed by Facebook Github Bot
parent 2b5283e39f
commit 8293e4c301
6 changed files with 17 additions and 41 deletions
+1 -4
View File
@@ -570,10 +570,7 @@ const ScrollResponderMixin = {
* down to make it meet the keyboard's top. Default is false.
*/
scrollResponderScrollNativeHandleToKeyboard: function<T>(
nodeHandle:
| number
| React.ElementRef<HostComponent<T>>
| React.ElementRef<Class<ReactNative.NativeComponent<T>>>,
nodeHandle: number | React.ElementRef<HostComponent<T>>,
additionalOffset?: number,
preventNegativeScrollOffset?: boolean,
) {
@@ -11,13 +11,10 @@
'use strict';
import * as React from 'react';
import type {
HostComponent,
_InternalReactNativeComponentClass,
} from '../Renderer/shims/ReactNativeTypes';
import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
function takesHostComponentInstance(
instance: React$ElementRef<HostComponent<mixed>> | null,
instance: React.ElementRef<HostComponent<mixed>> | null,
): void {}
const MyHostComponent = (('Host': any): HostComponent<mixed>);
@@ -33,20 +30,3 @@ const MyHostComponent = (('Host': any): HostComponent<mixed>);
hostComponentRef.measureLayout(hostComponentRef, () => {});
}}
/>;
declare var NativeComponent: _InternalReactNativeComponentClass<{...}>;
class MyNativeComponent extends NativeComponent {}
<MyNativeComponent
ref={nativeComponentRef => {
// $FlowExpectedError - NativeComponent cannot be passed as HostComponent.
takesHostComponentInstance(nativeComponentRef);
if (nativeComponentRef == null) {
return;
}
// $FlowExpectedError - NativeComponent cannot be passed as HostComponent.
nativeComponentRef.measureLayout(nativeComponentRef, () => {});
}}
/>;
-1
View File
@@ -150,7 +150,6 @@ jest
.NativeMethodsMixin;
Object.assign(NativeMethodsMixin, MockNativeMethods);
Object.assign(ReactNative.NativeComponent.prototype, MockNativeMethods);
return ReactNative;
})
@@ -16,13 +16,13 @@ const COMMANDS_EXPORTED_WITH_DIFFERENT_NAME = `
const codegenNativeComponent = require('codegenNativeComponent');
import type {ViewProps} from 'ViewPropTypes';
import type {NativeComponent} from 'codegenNativeComponent';
import type {NativeComponentType} from 'codegenNativeComponent';
type ModuleProps = $ReadOnly<{|
...ViewProps,
|}>;
type NativeType = NativeComponent<ModuleProps>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>) => void;
@@ -39,13 +39,13 @@ const OTHER_COMMANDS_EXPORT = `
const codegenNativeComponent = require('codegenNativeComponent');
import type {ViewProps} from 'ViewPropTypes';
import type {NativeComponent} from 'codegenNativeComponent';
import type {NativeComponentType} from 'codegenNativeComponent';
type ModuleProps = $ReadOnly<{|
...ViewProps,
|}>;
type NativeType = NativeComponent<ModuleProps>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>) => void;
@@ -60,7 +60,7 @@ const COMMANDS_EXPORTED_WITH_SHORTHAND = `
// @flow
const codegenNativeComponent = require('codegenNativeComponent');
import type {NativeComponent} from 'codegenNativeComponent';
import type {NativeComponentType} from 'codegenNativeComponent';
import type {ViewProps} from 'ViewPropTypes';
@@ -68,7 +68,7 @@ type ModuleProps = $ReadOnly<{|
...ViewProps,
|}>;
type NativeType = NativeComponent<ModuleProps>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>) => void;
@@ -27,7 +27,7 @@ import type {
DirectEventHandler,
WithDefault,
} from 'CodegenFlowtypes';
import type {NativeComponent} from 'codegenNativeComponent';
import type {NativeComponentType} from 'codegenNativeComponent';
import type {ViewProps} from 'ViewPropTypes';
@@ -42,7 +42,7 @@ type ModuleProps = $ReadOnly<{|
onBubblingEventDefinedInlineNull: BubblingEventHandler<null>,
|}>;
type NativeType = NativeComponent<ModuleProps>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void;
@@ -64,7 +64,7 @@ const FULL_NATIVE_COMPONENT_WITH_TYPE_EXPORT = `
const codegenNativeCommands = require('codegenNativeCommands');
const codegenNativeComponent = require('codegenNativeComponent');
import type {NativeComponent} from 'codegenNativeComponent';
import type {NativeComponentType} from 'codegenNativeComponent';
import type {
Int32,
@@ -86,7 +86,7 @@ type ModuleProps = $ReadOnly<{|
onBubblingEventDefinedInlineNull: BubblingEventHandler<null>,
|}>;
type NativeType = NativeComponent<ModuleProps>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void;
@@ -7,7 +7,7 @@ const codegenNativeCommands = require('codegenNativeCommands');
const codegenNativeComponent = require('codegenNativeComponent');
import type { Int32, BubblingEventHandler, DirectEventHandler, WithDefault } from 'CodegenFlowtypes';
import type { NativeComponent } from 'codegenNativeComponent';
import type { NativeComponentType } from 'codegenNativeComponent';
import type { ViewProps } from 'ViewPropTypes';
type ModuleProps = $ReadOnly<{| ...ViewProps,
// Props
@@ -16,7 +16,7 @@ type ModuleProps = $ReadOnly<{| ...ViewProps,
onDirectEventDefinedInlineNull: DirectEventHandler<null>,
onBubblingEventDefinedInlineNull: BubblingEventHandler<null>,
|}>;
type NativeType = NativeComponent<ModuleProps>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void,
+scrollTo: (viewRef: React.ElementRef<NativeType>, y: Int32, animated: boolean) => void,
@@ -71,7 +71,7 @@ const codegenNativeCommands = require('codegenNativeCommands');
const codegenNativeComponent = require('codegenNativeComponent');
import type { NativeComponent } from 'codegenNativeComponent';
import type { NativeComponentType } from 'codegenNativeComponent';
import type { Int32, BubblingEventHandler, DirectEventHandler, WithDefault } from 'CodegenFlowtypes';
import type { ViewProps } from 'ViewPropTypes';
type ModuleProps = $ReadOnly<{| ...ViewProps,
@@ -81,7 +81,7 @@ type ModuleProps = $ReadOnly<{| ...ViewProps,
onDirectEventDefinedInlineNull: DirectEventHandler<null>,
onBubblingEventDefinedInlineNull: BubblingEventHandler<null>,
|}>;
type NativeType = NativeComponent<ModuleProps>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void,
+scrollTo: (viewRef: React.ElementRef<NativeType>, y: Int32, animated: boolean) => void,