mirror of
https://github.com/react/react-native.git
synced 2026-09-28 13:23:09 +08:00
Add codegen for EdgeInset type diffing (#52239)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52239 Add `toDynamic` conversion function for `EdgeInset` which allowed for removing the custom conversion implemented for the `ViewProps`. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D77234069 fbshipit-source-id: 3aecad8a6d78468f0056167fa1523ccdfb68f369
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9b82e706fb
commit
3d97bac5f2
@@ -118,6 +118,10 @@ function generatePropsDiffString(
|
||||
result["${prop.name}"] = toDynamic(${prop.name});
|
||||
}`;
|
||||
case 'EdgeInsetsPrimitive':
|
||||
return `
|
||||
if (${prop.name} != oldProps->${prop.name}) {
|
||||
result["${prop.name}"] = toDynamic(${prop.name});
|
||||
}`;
|
||||
case 'DimensionPrimitive':
|
||||
// TODO: Implement diffProps for complex types
|
||||
return '';
|
||||
|
||||
+3
@@ -900,6 +900,9 @@ folly::dynamic InsetsPropNativeComponentProps::getDiffProps(
|
||||
}
|
||||
folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps);
|
||||
|
||||
if (contentInset != oldProps->contentInset) {
|
||||
result[\\"contentInset\\"] = toDynamic(contentInset);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
-9
@@ -530,15 +530,6 @@ static folly::dynamic toDynamic(const std::vector<FilterFunction>& filter) {
|
||||
return filterResult;
|
||||
}
|
||||
|
||||
static folly::dynamic toDynamic(const EdgeInsets& edgeInsets) {
|
||||
folly::dynamic edgeInsetsResult = folly::dynamic::object();
|
||||
edgeInsetsResult["left"] = edgeInsets.left;
|
||||
edgeInsetsResult["top"] = edgeInsets.top;
|
||||
edgeInsetsResult["right"] = edgeInsets.right;
|
||||
edgeInsetsResult["bottom"] = edgeInsets.bottom;
|
||||
return edgeInsetsResult;
|
||||
}
|
||||
|
||||
ComponentName HostPlatformViewProps::getDiffPropsImplementationTarget() const {
|
||||
return "View";
|
||||
}
|
||||
|
||||
@@ -178,6 +178,17 @@ inline void fromRawValue(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RN_SERIALIZABLE_STATE
|
||||
inline folly::dynamic toDynamic(const EdgeInsets& edgeInsets) {
|
||||
folly::dynamic edgeInsetsResult = folly::dynamic::object();
|
||||
edgeInsetsResult["left"] = edgeInsets.left;
|
||||
edgeInsetsResult["top"] = edgeInsets.top;
|
||||
edgeInsetsResult["right"] = edgeInsets.right;
|
||||
edgeInsetsResult["bottom"] = edgeInsets.bottom;
|
||||
return edgeInsetsResult;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void fromRawValue(
|
||||
const PropsParserContext& context,
|
||||
const RawValue& value,
|
||||
|
||||
Reference in New Issue
Block a user