Skip to content

Commit

Permalink
Partial React Sync
Browse files Browse the repository at this point in the history
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](facebook/react@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 facebook/react#16879
- Eli's PR to remove setNativeProps warning facebook/react#17045

Reviewed By: gaearon

Differential Revision: D17828989

fbshipit-source-id: 75c99737f2dec4889d7d453bbdebaeb47656b5ce
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Oct 9, 2019
1 parent 2fbcdad commit 90a9d59
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 269 deletions.
4 changes: 2 additions & 2 deletions Libraries/Renderer/__flowtests__/ReactNativeTypes-flowtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import * as React from 'react';
import type {
HostComponent,
ReactNativeComponentClass_ForTestsOnly,
_InternalReactNativeComponentClass,
} from '../shims/ReactNativeTypes';

function takesHostComponentInstance(
Expand All @@ -34,7 +34,7 @@ const MyHostComponent = (('Host': any): HostComponent<mixed>);
}}
/>;

declare var NativeComponent: ReactNativeComponentClass_ForTestsOnly<{}>;
declare var NativeComponent: _InternalReactNativeComponentClass<{}>;
class MyNativeComponent extends NativeComponent {}

<MyNativeComponent
Expand Down
35 changes: 2 additions & 33 deletions Libraries/Renderer/implementations/ReactFabric-dev.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2804,7 +2804,6 @@ var debugRenderPhaseSideEffectsForStrictMode = true;

var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
var warnAboutDeprecatedLifecycles = true;
var warnAboutDeprecatedSetNativeProps = true;
var enableFlareAPI = false;
var enableFundamentalAPI = false;

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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;
Expand Down
35 changes: 2 additions & 33 deletions Libraries/Renderer/implementations/ReactFabric-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,6 @@ var enableProfilerTimer = true;
var enableSchedulerTracing = true;
var enableSuspenseServerRenderer = false;

var warnAboutDeprecatedSetNativeProps = false;
var enableFlareAPI = false;
var enableFundamentalAPI = false;

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion Libraries/Renderer/implementations/ReactFabric-prod.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
1 change: 0 additions & 1 deletion Libraries/Renderer/implementations/ReactFabric-prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
71 changes: 4 additions & 67 deletions Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2658,7 +2658,6 @@ var debugRenderPhaseSideEffectsForStrictMode = true;

var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
var warnAboutDeprecatedLifecycles = true;
var warnAboutDeprecatedSetNativeProps = true;
var enableFlareAPI = false;
var enableFundamentalAPI = false;

Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -23031,9 +22971,6 @@ var ReactNativeRenderer = {
args
);
},

setNativeProps: setNativeProps,

render: function(element, containerTag, callback) {
var root = roots.get(containerTag);

Expand Down
Loading

0 comments on commit 90a9d59

Please sign in to comment.