diff --git a/ReactCommon/fabric/core/propsConversions.h b/ReactCommon/fabric/core/propsConversions.h index 548b88f3d..bf2f96f6c 100644 --- a/ReactCommon/fabric/core/propsConversions.h +++ b/ReactCommon/fabric/core/propsConversions.h @@ -17,7 +17,11 @@ namespace facebook { namespace react { inline void fromDynamic(const folly::dynamic &value, bool &result) { result = value.getBool(); } -inline void fromDynamic(const folly::dynamic &value, int &result) { result = value.getInt(); } +inline void fromDynamic(const folly::dynamic &value, int &result) { + // All numbers from JS are treated as double, and JS cannot represent int64 in practice. + // So this always converts the value to int64 instead. + result = value.asInt(); +} inline void fromDynamic(const folly::dynamic &value, std::string &result) { result = value.getString(); } template diff --git a/ReactCommon/fabric/view/conversions.h b/ReactCommon/fabric/view/conversions.h index cec142a7b..66cb25da0 100644 --- a/ReactCommon/fabric/view/conversions.h +++ b/ReactCommon/fabric/view/conversions.h @@ -201,7 +201,7 @@ inline void fromDynamic(const folly::dynamic &value, YGValue &result) { return; } else { if (stringValue.back() == '%') { - result = { folly::to(stringValue.substr(stringValue.length() - 1)), YGUnitPercent }; + result = { folly::to(stringValue.substr(0, stringValue.length() - 1)), YGUnitPercent }; return; } else { result = { folly::to(stringValue), YGUnitPoint };