Skip to content

Commit a073080

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Fix serialization for vector of primitive type (#53982)
Summary: Pull Request resolved: #53982 This diffs adds specific `toDynamic` conversions for props defined as arrays holding primitive types. This fixes the serialization of `std::vector<Float>` that was failing to correctly convert to a `folly::dynamic` type when using Props 2.0. Changelog: [Internal] Reviewed By: Abbondanzo Differential Revision: D83520605 fbshipit-source-id: 80a6ce2b3a265601f945ff3b76840c04e46aacdc
1 parent 5a4ed2d commit a073080

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/react-native/ReactCommon/react/renderer/core/propsConversions.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ inline folly::dynamic toDynamic(const std::vector<std::string>& arrayValue) {
3434
return resultArray;
3535
}
3636

37+
inline folly::dynamic toDynamic(const std::vector<int>& arrayValue) {
38+
folly::dynamic resultArray = folly::dynamic::array();
39+
for (auto value : arrayValue) {
40+
resultArray.push_back(value);
41+
}
42+
return resultArray;
43+
}
44+
45+
inline folly::dynamic toDynamic(const std::vector<double>& arrayValue) {
46+
folly::dynamic resultArray = folly::dynamic::array();
47+
for (auto value : arrayValue) {
48+
resultArray.push_back(value);
49+
}
50+
return resultArray;
51+
}
52+
53+
inline folly::dynamic toDynamic(const std::vector<Float>& arrayValue) {
54+
folly::dynamic resultArray = folly::dynamic::array();
55+
for (auto value : arrayValue) {
56+
resultArray.push_back(value);
57+
}
58+
return resultArray;
59+
}
60+
3761
inline folly::dynamic toDynamic(const std::vector<folly::dynamic>& arrayValue) {
3862
folly::dynamic resultArray = folly::dynamic::array();
3963
for (auto& value : arrayValue) {

0 commit comments

Comments
 (0)