mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add toDynamic conversion function for ImageSource (#52237)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52237 For array props conversion following later in this stack, each type should have a toDynamic conversion available that can be called upon to convert all supported types to a `folly::dynamic` result. This diff adds the toDynamic conversion function for `ImageSource` Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D77234063 fbshipit-source-id: 392cbaf172595936f7f66faa824900dadd58bdcf
This commit is contained in:
committed by
Facebook GitHub Bot
parent
dca83bc158
commit
da0938edfd
+2
-2
@@ -532,7 +532,7 @@ folly::dynamic ImagePropNativeComponentViewProps::getDiffProps(
|
||||
folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps);
|
||||
|
||||
if (thumbImage != oldProps->thumbImage) {
|
||||
result[\\"thumbImage\\"] = thumbImage.toDynamic();
|
||||
result[\\"thumbImage\\"] = toDynamic(thumbImage);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -740,7 +740,7 @@ folly::dynamic MultiNativePropNativeComponentViewProps::getDiffProps(
|
||||
folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps);
|
||||
|
||||
if (thumbImage != oldProps->thumbImage) {
|
||||
result[\\"thumbImage\\"] = thumbImage.toDynamic();
|
||||
result[\\"thumbImage\\"] = toDynamic(thumbImage);
|
||||
}
|
||||
|
||||
if (color != oldProps->color) {
|
||||
|
||||
+2
-2
@@ -532,7 +532,7 @@ folly::dynamic ImagePropNativeComponentViewProps::getDiffProps(
|
||||
folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps);
|
||||
|
||||
if (thumbImage != oldProps->thumbImage) {
|
||||
result[\\"thumbImage\\"] = thumbImage.toDynamic();
|
||||
result[\\"thumbImage\\"] = toDynamic(thumbImage);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -740,7 +740,7 @@ folly::dynamic MultiNativePropNativeComponentViewProps::getDiffProps(
|
||||
folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps);
|
||||
|
||||
if (thumbImage != oldProps->thumbImage) {
|
||||
result[\\"thumbImage\\"] = thumbImage.toDynamic();
|
||||
result[\\"thumbImage\\"] = toDynamic(thumbImage);
|
||||
}
|
||||
|
||||
if (color != oldProps->color) {
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ function generatePropsDiffString(
|
||||
case 'ImageSourcePrimitive':
|
||||
return `
|
||||
if (${prop.name} != oldProps->${prop.name}) {
|
||||
result["${prop.name}"] = ${prop.name}.toDynamic();
|
||||
result["${prop.name}"] = toDynamic(${prop.name});
|
||||
}`;
|
||||
case 'ImageRequestPrimitive':
|
||||
// Shouldn't be used in props
|
||||
|
||||
+2
-2
@@ -852,7 +852,7 @@ folly::dynamic ImagePropNativeComponentProps::getDiffProps(
|
||||
folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps);
|
||||
|
||||
if (thumbImage != oldProps->thumbImage) {
|
||||
result[\\"thumbImage\\"] = thumbImage.toDynamic();
|
||||
result[\\"thumbImage\\"] = toDynamic(thumbImage);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1152,7 +1152,7 @@ folly::dynamic ImageColorPropNativeComponentProps::getDiffProps(
|
||||
folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps);
|
||||
|
||||
if (thumbImage != oldProps->thumbImage) {
|
||||
result[\\"thumbImage\\"] = thumbImage.toDynamic();
|
||||
result[\\"thumbImage\\"] = toDynamic(thumbImage);
|
||||
}
|
||||
|
||||
if (color != oldProps->color) {
|
||||
|
||||
@@ -201,17 +201,17 @@ folly::dynamic ImageProps::getDiffProps(const Props* prevProps) const {
|
||||
if (sources != oldProps->sources) {
|
||||
auto sourcesArray = folly::dynamic::array();
|
||||
for (const auto& source : sources) {
|
||||
sourcesArray.push_back(source.toDynamic());
|
||||
sourcesArray.push_back(toDynamic(source));
|
||||
}
|
||||
result["source"] = sourcesArray;
|
||||
}
|
||||
|
||||
if (defaultSource != oldProps->defaultSource) {
|
||||
result["defaultSource"] = defaultSource.toDynamic();
|
||||
result["defaultSource"] = toDynamic(defaultSource);
|
||||
}
|
||||
|
||||
if (loadingIndicatorSource != oldProps->loadingIndicatorSource) {
|
||||
result["loadingIndicatorSource"] = loadingIndicatorSource.toDynamic();
|
||||
result["loadingIndicatorSource"] = toDynamic(loadingIndicatorSource);
|
||||
}
|
||||
|
||||
if (resizeMode != oldProps->resizeMode) {
|
||||
|
||||
@@ -92,6 +92,12 @@ class ImageSource {
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef RN_SERIALIZABLE_STATE
|
||||
inline folly::dynamic toDynamic(const ImageSource& imageSource) {
|
||||
return imageSource.toDynamic();
|
||||
}
|
||||
#endif
|
||||
|
||||
using ImageSources = std::vector<ImageSource>;
|
||||
|
||||
enum class ImageResizeMode {
|
||||
|
||||
Reference in New Issue
Block a user