Partial React Sync

Summary:
This diff is a partial sync of React into React Native.

## Source
The source branch is from my fork [here](https://github.com/facebook/react/compare/master...rickhanlonii:react-native-partial-sync-october-9?expand=1)

This branch is created from D17456249 which partially synced Dan's branch [here](https://github.com/facebook/react/compare/master...gaearon:partsync).

To create my branch, I forked from Dan's branch and added two commits from these PRs:

- Joshua's PR to improve view config errors https://github.com/facebook/react/pull/16879
- Eli's PR to remove setNativeProps warning https://github.com/facebook/react/pull/17045

Reviewed By: gaearon

Differential Revision: D17828989

fbshipit-source-id: 75c99737f2dec4889d7d453bbdebaeb47656b5ce
This commit is contained in:
Rick Hanlon
2019-10-09 09:37:03 -07:00
committed by Facebook Github Bot
parent 2fbcdad09c
commit 90a9d59679
14 changed files with 15 additions and 269 deletions
@@ -13,7 +13,7 @@
import * as React from 'react';
import type {
HostComponent,
ReactNativeComponentClass_ForTestsOnly,
_InternalReactNativeComponentClass,
} from '../shims/ReactNativeTypes';
function takesHostComponentInstance(
@@ -34,7 +34,7 @@ const MyHostComponent = (('Host': any): HostComponent<mixed>);
}}
/>;
declare var NativeComponent: ReactNativeComponentClass_ForTestsOnly<{}>;
declare var NativeComponent: _InternalReactNativeComponentClass<{}>;
class MyNativeComponent extends NativeComponent {}
<MyNativeComponent
@@ -2804,7 +2804,6 @@ var debugRenderPhaseSideEffectsForStrictMode = true;
var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
var warnAboutDeprecatedLifecycles = true;
var warnAboutDeprecatedSetNativeProps = true;
var enableFlareAPI = false;
var enableFundamentalAPI = false;
@@ -3827,6 +3826,8 @@ var ReactNativeComponent = (function(_React$Component) {
return ReactNativeComponent;
})(React.Component);
// This type is only used for FlowTests. It shouldn't be imported directly
/**
* This type keeps ReactNativeFiberHostComponent and NativeMethodsMixin in sync.
* It can also provide types for ReactNative applications that use NMM or refs.
@@ -22798,18 +22799,6 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) {
return;
}
{
if (warnAboutDeprecatedSetNativeProps) {
warningWithoutStack$1(
false,
"Warning: Calling ref.setNativeProps(nativeProps) " +
"is deprecated and will be removed in a future release. " +
"Use the setNativeProps export from the react-native package instead." +
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n"
);
}
}
var nativeTag =
maybeInstance._nativeTag || maybeInstance.canonical._nativeTag;
var viewConfig =
@@ -23185,18 +23174,6 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) {
return;
}
{
if (warnAboutDeprecatedSetNativeProps) {
warningWithoutStack$1(
false,
"Warning: Calling ref.setNativeProps(nativeProps) " +
"is deprecated and will be removed in a future release. " +
"Use the setNativeProps export from the react-native package instead." +
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n"
);
}
}
var nativeTag =
maybeInstance._nativeTag || maybeInstance.canonical._nativeTag;
var viewConfig =
@@ -23408,14 +23385,6 @@ var ReactFabric = {
findNodeHandle: findNodeHandle,
setNativeProps: function(handle, nativeProps) {
warningWithoutStack$1(
false,
"Warning: setNativeProps is not currently supported in Fabric"
);
return;
},
dispatchCommand: function(handle, command, args) {
var invalid =
handle._nativeTag == null || handle._internalInstanceHandle == null;
@@ -2800,7 +2800,6 @@ var enableProfilerTimer = true;
var enableSchedulerTracing = true;
var enableSuspenseServerRenderer = false;
var warnAboutDeprecatedSetNativeProps = false;
var enableFlareAPI = false;
var enableFundamentalAPI = false;
@@ -3823,6 +3822,8 @@ var ReactNativeComponent = (function(_React$Component) {
return ReactNativeComponent;
})(React.Component);
// This type is only used for FlowTests. It shouldn't be imported directly
/**
* This type keeps ReactNativeFiberHostComponent and NativeMethodsMixin in sync.
* It can also provide types for ReactNative applications that use NMM or refs.
@@ -22794,18 +22795,6 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) {
return;
}
{
if (warnAboutDeprecatedSetNativeProps) {
warningWithoutStack$1(
false,
"Warning: Calling ref.setNativeProps(nativeProps) " +
"is deprecated and will be removed in a future release. " +
"Use the setNativeProps export from the react-native package instead." +
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n"
);
}
}
var nativeTag =
maybeInstance._nativeTag || maybeInstance.canonical._nativeTag;
var viewConfig =
@@ -23181,18 +23170,6 @@ var ReactNativeComponent$1 = function(findNodeHandle, findHostInstance) {
return;
}
{
if (warnAboutDeprecatedSetNativeProps) {
warningWithoutStack$1(
false,
"Warning: Calling ref.setNativeProps(nativeProps) " +
"is deprecated and will be removed in a future release. " +
"Use the setNativeProps export from the react-native package instead." +
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n"
);
}
}
var nativeTag =
maybeInstance._nativeTag || maybeInstance.canonical._nativeTag;
var viewConfig =
@@ -23404,14 +23381,6 @@ var ReactFabric = {
findNodeHandle: findNodeHandle,
setNativeProps: function(handle, nativeProps) {
warningWithoutStack$1(
false,
"Warning: setNativeProps is not currently supported in Fabric"
);
return;
},
dispatchCommand: function(handle, command, args) {
var invalid =
handle._nativeTag == null || handle._internalInstanceHandle == null;
@@ -7605,7 +7605,6 @@ var roots = new Map(),
})(React.Component);
})(findNodeHandle, findHostInstance),
findNodeHandle: findNodeHandle,
setNativeProps: function() {},
dispatchCommand: function(handle, command, args) {
null != handle._nativeTag &&
null != handle._internalInstanceHandle &&
@@ -7605,7 +7605,6 @@ var roots = new Map(),
})(React.Component);
})(findNodeHandle, findHostInstance),
findNodeHandle: findNodeHandle,
setNativeProps: function() {},
dispatchCommand: function(handle, command, args) {
null != handle._nativeTag &&
null != handle._internalInstanceHandle &&
@@ -7838,7 +7838,6 @@ var roots = new Map(),
})(React.Component);
})(findNodeHandle, findHostInstance),
findNodeHandle: findNodeHandle,
setNativeProps: function() {},
dispatchCommand: function(handle, command, args) {
null != handle._nativeTag &&
null != handle._internalInstanceHandle &&
@@ -7838,7 +7838,6 @@ var roots = new Map(),
})(React.Component);
})(findNodeHandle, findHostInstance),
findNodeHandle: findNodeHandle,
setNativeProps: function() {},
dispatchCommand: function(handle, command, args) {
null != handle._nativeTag &&
null != handle._internalInstanceHandle &&
@@ -2658,7 +2658,6 @@ var debugRenderPhaseSideEffectsForStrictMode = true;
var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
var warnAboutDeprecatedLifecycles = true;
var warnAboutDeprecatedSetNativeProps = true;
var enableFlareAPI = false;
var enableFundamentalAPI = false;
@@ -3928,9 +3927,13 @@ var ReactNativeFiberHostComponent = (function() {
} else if (relativeToNativeNode._nativeTag) {
relativeNode = relativeToNativeNode._nativeTag;
} else if (
/* $FlowFixMe canonical doesn't exist on the node.
I think this branch is dead and will remove it in a followup */
relativeToNativeNode.canonical &&
relativeToNativeNode.canonical._nativeTag
) {
/* $FlowFixMe canonical doesn't exist on the node.
I think this branch is dead and will remove it in a followup */
relativeNode = relativeToNativeNode.canonical._nativeTag;
}
@@ -3955,15 +3958,6 @@ var ReactNativeFiberHostComponent = (function() {
nativeProps
) {
{
if (warnAboutDeprecatedSetNativeProps) {
warningWithoutStack$1(
false,
"Warning: Calling ref.setNativeProps(nativeProps) " +
"is deprecated and will be removed in a future release. " +
"Use the setNativeProps export from the react-native package instead." +
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n"
);
}
warnForStyleProps(nativeProps, this.viewConfig.validAttributes);
}
@@ -22374,18 +22368,6 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) {
return;
}
{
if (warnAboutDeprecatedSetNativeProps) {
warningWithoutStack$1(
false,
"Warning: Calling ref.setNativeProps(nativeProps) " +
"is deprecated and will be removed in a future release. " +
"Use the setNativeProps export from the react-native package instead." +
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n"
);
}
}
var nativeTag =
maybeInstance._nativeTag || maybeInstance.canonical._nativeTag;
var viewConfig =
@@ -22761,18 +22743,6 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) {
return;
}
{
if (warnAboutDeprecatedSetNativeProps) {
warningWithoutStack$1(
false,
"Warning: Calling ref.setNativeProps(nativeProps) " +
"is deprecated and will be removed in a future release. " +
"Use the setNativeProps export from the react-native package instead." +
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n"
);
}
}
var nativeTag =
maybeInstance._nativeTag || maybeInstance.canonical._nativeTag;
var viewConfig =
@@ -22907,36 +22877,6 @@ var getInspectorDataForViewTag = void 0;
};
}
// Module provided by RN:
function setNativeProps(handle, nativeProps) {
if (handle._nativeTag == null) {
!(handle._nativeTag != null)
? warningWithoutStack$1(
false,
"setNativeProps was called with a ref that isn't a " +
"native component. Use React.forwardRef to get access to the underlying native component"
)
: void 0;
return;
}
{
warnForStyleProps(nativeProps, handle.viewConfig.validAttributes);
}
var updatePayload = create(nativeProps, handle.viewConfig.validAttributes);
// Avoid the overhead of bridge calls if there's no update.
// This is an expensive no-op for Android, and causes an unnecessary
// view invalidation for certain components (eg RCTTextInput) on iOS.
if (updatePayload != null) {
ReactNativePrivateInterface.UIManager.updateView(
handle._nativeTag,
handle.viewConfig.uiViewClassName,
updatePayload
);
}
}
// TODO: direct imports like some-package/src/* are bad. Fix me.
// Module provided by RN:
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
@@ -23031,9 +22971,6 @@ var ReactNativeRenderer = {
args
);
},
setNativeProps: setNativeProps,
render: function(element, containerTag, callback) {
var root = roots.get(containerTag);
@@ -2654,7 +2654,6 @@ var enableProfilerTimer = true;
var enableSchedulerTracing = true;
var enableSuspenseServerRenderer = false;
var warnAboutDeprecatedSetNativeProps = false;
var enableFlareAPI = false;
var enableFundamentalAPI = false;
@@ -3924,9 +3923,13 @@ var ReactNativeFiberHostComponent = (function() {
} else if (relativeToNativeNode._nativeTag) {
relativeNode = relativeToNativeNode._nativeTag;
} else if (
/* $FlowFixMe canonical doesn't exist on the node.
I think this branch is dead and will remove it in a followup */
relativeToNativeNode.canonical &&
relativeToNativeNode.canonical._nativeTag
) {
/* $FlowFixMe canonical doesn't exist on the node.
I think this branch is dead and will remove it in a followup */
relativeNode = relativeToNativeNode.canonical._nativeTag;
}
@@ -3951,15 +3954,6 @@ var ReactNativeFiberHostComponent = (function() {
nativeProps
) {
{
if (warnAboutDeprecatedSetNativeProps) {
warningWithoutStack$1(
false,
"Warning: Calling ref.setNativeProps(nativeProps) " +
"is deprecated and will be removed in a future release. " +
"Use the setNativeProps export from the react-native package instead." +
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n"
);
}
warnForStyleProps(nativeProps, this.viewConfig.validAttributes);
}
@@ -22370,18 +22364,6 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) {
return;
}
{
if (warnAboutDeprecatedSetNativeProps) {
warningWithoutStack$1(
false,
"Warning: Calling ref.setNativeProps(nativeProps) " +
"is deprecated and will be removed in a future release. " +
"Use the setNativeProps export from the react-native package instead." +
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n"
);
}
}
var nativeTag =
maybeInstance._nativeTag || maybeInstance.canonical._nativeTag;
var viewConfig =
@@ -22757,18 +22739,6 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) {
return;
}
{
if (warnAboutDeprecatedSetNativeProps) {
warningWithoutStack$1(
false,
"Warning: Calling ref.setNativeProps(nativeProps) " +
"is deprecated and will be removed in a future release. " +
"Use the setNativeProps export from the react-native package instead." +
"\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n"
);
}
}
var nativeTag =
maybeInstance._nativeTag || maybeInstance.canonical._nativeTag;
var viewConfig =
@@ -22903,36 +22873,6 @@ var getInspectorDataForViewTag = void 0;
};
}
// Module provided by RN:
function setNativeProps(handle, nativeProps) {
if (handle._nativeTag == null) {
!(handle._nativeTag != null)
? warningWithoutStack$1(
false,
"setNativeProps was called with a ref that isn't a " +
"native component. Use React.forwardRef to get access to the underlying native component"
)
: void 0;
return;
}
{
warnForStyleProps(nativeProps, handle.viewConfig.validAttributes);
}
var updatePayload = create(nativeProps, handle.viewConfig.validAttributes);
// Avoid the overhead of bridge calls if there's no update.
// This is an expensive no-op for Android, and causes an unnecessary
// view invalidation for certain components (eg RCTTextInput) on iOS.
if (updatePayload != null) {
ReactNativePrivateInterface.UIManager.updateView(
handle._nativeTag,
handle.viewConfig.uiViewClassName,
updatePayload
);
}
}
// TODO: direct imports like some-package/src/* are bad. Fix me.
// Module provided by RN:
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
@@ -23027,9 +22967,6 @@ var ReactNativeRenderer = {
args
);
},
setNativeProps: setNativeProps,
render: function(element, containerTag, callback) {
var root = roots.get(containerTag);
@@ -7783,21 +7783,6 @@ var roots = new Map(),
args
);
},
setNativeProps: function(handle, nativeProps) {
null != handle._nativeTag &&
((nativeProps = diffProperties(
null,
emptyObject,
nativeProps,
handle.viewConfig.validAttributes
)),
null != nativeProps &&
ReactNativePrivateInterface.UIManager.updateView(
handle._nativeTag,
handle.viewConfig.uiViewClassName,
nativeProps
));
},
render: function(element, containerTag, callback) {
var root = roots.get(containerTag);
if (!root) {
@@ -7783,21 +7783,6 @@ var roots = new Map(),
args
);
},
setNativeProps: function(handle, nativeProps) {
null != handle._nativeTag &&
((nativeProps = diffProperties(
null,
emptyObject,
nativeProps,
handle.viewConfig.validAttributes
)),
null != nativeProps &&
ReactNativePrivateInterface.UIManager.updateView(
handle._nativeTag,
handle.viewConfig.uiViewClassName,
nativeProps
));
},
render: function(element, containerTag, callback) {
var root = roots.get(containerTag);
if (!root) {
@@ -8013,21 +8013,6 @@ var roots = new Map(),
args
);
},
setNativeProps: function(handle, nativeProps) {
null != handle._nativeTag &&
((nativeProps = diffProperties(
null,
emptyObject,
nativeProps,
handle.viewConfig.validAttributes
)),
null != nativeProps &&
ReactNativePrivateInterface.UIManager.updateView(
handle._nativeTag,
handle.viewConfig.uiViewClassName,
nativeProps
));
},
render: function(element, containerTag, callback) {
var root = roots.get(containerTag);
if (!root) {
@@ -8013,21 +8013,6 @@ var roots = new Map(),
args
);
},
setNativeProps: function(handle, nativeProps) {
null != handle._nativeTag &&
((nativeProps = diffProperties(
null,
emptyObject,
nativeProps,
handle.viewConfig.validAttributes
)),
null != nativeProps &&
ReactNativePrivateInterface.UIManager.updateView(
handle._nativeTag,
handle.viewConfig.uiViewClassName,
nativeProps
));
},
render: function(element, containerTag, callback) {
var root = roots.get(containerTag);
if (!root) {
+1 -3
View File
@@ -98,7 +98,7 @@ class ReactNativeComponent<Props> extends React.Component<Props> {
}
// This type is only used for FlowTests. It shouldn't be imported directly
export type ReactNativeComponentClass_ForTestsOnly<Props> = Class<
export type _InternalReactNativeComponentClass<Props> = Class<
ReactNativeComponent<Props>,
>;
@@ -144,7 +144,6 @@ export type ReactNativeType = {
NativeComponent: typeof ReactNativeComponent,
findNodeHandle(componentOrHandle: any): ?number,
dispatchCommand(handle: any, command: string, args: Array<any>): void,
setNativeProps(handle: any, nativeProps: Object): void,
render(
element: React$Element<any>,
containerTag: any,
@@ -161,7 +160,6 @@ export type ReactFabricType = {
NativeComponent: typeof ReactNativeComponent,
findNodeHandle(componentOrHandle: any): ?number,
dispatchCommand(handle: any, command: string, args: Array<any>): void,
setNativeProps(handle: any, nativeProps: Object): void,
render(
element: React$Element<any>,
containerTag: any,