Patch setNativeProps in OSS build
Summary: changelog: [internal] `setNativeProps` have been implemented in Fabric but require a React change to be accessible from JavaScript components. For React sync to be imported in OSS builds, React needs to have have a new release in NPM. To work around this limitation, I manually copied over lines of code that glue together setNativeProps to OSS build. Reviewed By: cortinico, cipolleschi Differential Revision: D44216496 fbshipit-source-id: b34b598c1a317bdc03cc5a4cadb3f7c610059709
This commit is contained in:
Родитель
8c01b56f12
Коммит
7b916be03f
|
@ -3419,6 +3419,23 @@ function mountSafeCallback_NOT_REALLY_SAFE(context, callback) {
|
|||
return callback.apply(context, arguments);
|
||||
};
|
||||
}
|
||||
function warnForStyleProps(props, validAttributes) {
|
||||
{
|
||||
for (var key in validAttributes.style) {
|
||||
if (!(validAttributes[key] || props[key] === undefined)) {
|
||||
error(
|
||||
"You are setting the style `{ %s" +
|
||||
": ... }` as a prop. You " +
|
||||
"should nest it in a style object. " +
|
||||
"E.g. `{ style: { %s" +
|
||||
": ... } }`",
|
||||
key,
|
||||
key
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Modules provided by RN:
|
||||
var emptyObject = {};
|
||||
|
@ -5100,7 +5117,8 @@ var _nativeFabricUIManage = nativeFabricUIManager,
|
|||
FabricDefaultPriority = _nativeFabricUIManage.unstable_DefaultEventPriority,
|
||||
FabricDiscretePriority = _nativeFabricUIManage.unstable_DiscreteEventPriority,
|
||||
fabricGetCurrentEventPriority =
|
||||
_nativeFabricUIManage.unstable_getCurrentEventPriority;
|
||||
_nativeFabricUIManage.unstable_getCurrentEventPriority,
|
||||
_setNativeProps = _nativeFabricUIManage.setNativeProps;
|
||||
var getViewConfigForType =
|
||||
ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get; // Counter for uniquely identifying views.
|
||||
// % 10 === 1 means it is a rootTag.
|
||||
|
@ -5199,10 +5217,15 @@ var ReactFabricHostComponent = /*#__PURE__*/ (function() {
|
|||
|
||||
_proto.setNativeProps = function setNativeProps(nativeProps) {
|
||||
{
|
||||
error("Warning: setNativeProps is not currently supported in Fabric");
|
||||
warnForStyleProps(nativeProps, this.viewConfig.validAttributes);
|
||||
}
|
||||
|
||||
return;
|
||||
var updatePayload = create(nativeProps, this.viewConfig.validAttributes);
|
||||
var stateNode = this._internalInstanceHandle.stateNode;
|
||||
|
||||
if (stateNode != null && updatePayload != null) {
|
||||
_setNativeProps(stateNode.node, updatePayload);
|
||||
}
|
||||
}; // This API (addEventListener, removeEventListener) attempts to adhere to the
|
||||
// w3 Level2 Events spec as much as possible, treating HostComponent as a DOM node.
|
||||
//
|
||||
|
|
|
@ -1922,6 +1922,7 @@ var _nativeFabricUIManage = nativeFabricUIManager,
|
|||
FabricDiscretePriority = _nativeFabricUIManage.unstable_DiscreteEventPriority,
|
||||
fabricGetCurrentEventPriority =
|
||||
_nativeFabricUIManage.unstable_getCurrentEventPriority,
|
||||
_setNativeProps = _nativeFabricUIManage.setNativeProps,
|
||||
getViewConfigForType =
|
||||
ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get,
|
||||
nextReactTag = 2;
|
||||
|
@ -1979,7 +1980,18 @@ var ReactFabricHostComponent = (function() {
|
|||
);
|
||||
}
|
||||
};
|
||||
_proto.setNativeProps = function() {};
|
||||
_proto.setNativeProps = function(nativeProps) {
|
||||
nativeProps = diffProperties(
|
||||
null,
|
||||
emptyObject,
|
||||
nativeProps,
|
||||
this.viewConfig.validAttributes
|
||||
);
|
||||
var stateNode = this._internalInstanceHandle.stateNode;
|
||||
null != stateNode &&
|
||||
null != nativeProps &&
|
||||
_setNativeProps(stateNode.node, nativeProps);
|
||||
};
|
||||
_proto.addEventListener_unstable = function(eventType, listener, options) {
|
||||
if ("string" !== typeof eventType)
|
||||
throw Error("addEventListener_unstable eventType must be a string");
|
||||
|
|
|
@ -1981,6 +1981,7 @@ var _nativeFabricUIManage = nativeFabricUIManager,
|
|||
FabricDiscretePriority = _nativeFabricUIManage.unstable_DiscreteEventPriority,
|
||||
fabricGetCurrentEventPriority =
|
||||
_nativeFabricUIManage.unstable_getCurrentEventPriority,
|
||||
_setNativeProps = _nativeFabricUIManage.setNativeProps,
|
||||
getViewConfigForType =
|
||||
ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get,
|
||||
nextReactTag = 2;
|
||||
|
@ -2038,7 +2039,18 @@ var ReactFabricHostComponent = (function() {
|
|||
);
|
||||
}
|
||||
};
|
||||
_proto.setNativeProps = function() {};
|
||||
_proto.setNativeProps = function(nativeProps) {
|
||||
nativeProps = diffProperties(
|
||||
null,
|
||||
emptyObject,
|
||||
nativeProps,
|
||||
this.viewConfig.validAttributes
|
||||
);
|
||||
var stateNode = this._internalInstanceHandle.stateNode;
|
||||
null != stateNode &&
|
||||
null != nativeProps &&
|
||||
_setNativeProps(stateNode.node, nativeProps);
|
||||
};
|
||||
_proto.addEventListener_unstable = function(eventType, listener, options) {
|
||||
if ("string" !== typeof eventType)
|
||||
throw Error("addEventListener_unstable eventType must be a string");
|
||||
|
|
Загрузка…
Ссылка в новой задаче