Skip to content

Commit

Permalink
Fabric: Additional temporary checks in prop parsing infra
Browse files Browse the repository at this point in the history
Summary:
While ViewConfig infra isn't perfect we need to check some value for correctness during prop-parsing.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D20639055

fbshipit-source-id: 193dcd0769bc7777bc8d60c964ede72ebdaa83e4
  • Loading branch information
shergin authored and facebook-github-bot committed Mar 25, 2020
1 parent 0b9ea60 commit fb02328
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions ReactCommon/fabric/components/image/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,35 @@ inline void fromRawValue(const RawValue &value, ImageSource &result) {
result.scale = items.find("deprecated") != items.end() ? 0.0 : 1.0;
}

if (items.find("url") != items.end()) {
if (items.find("url") != items.end() &&
// The following should be removed after codegen is shipped.
// See T45151459.
items.at("url").hasType<std::string>()) {
result.uri = (std::string)items.at("url");
}

if (items.find("uri") != items.end()) {
if (items.find("uri") != items.end() &&
// The following should be removed after codegen is shipped.
// See T45151459.
items.at("uri").hasType<std::string>()) {
result.uri = (std::string)items.at("uri");
}

if (items.find("bundle") != items.end()) {
if (items.find("bundle") != items.end() &&
// The following should be removed after codegen is shipped.
// See T45151459.
items.at("bundle").hasType<std::string>()) {
result.bundle = (std::string)items.at("bundle");
result.type = ImageSource::Type::Local;
}

return;
}

abort();
// The following should be removed after codegen is shipped.
// See T45151459.
result = {};
result.type = ImageSource::Type::Invalid;
}

inline std::string toString(const ImageSource &value) {
Expand Down

0 comments on commit fb02328

Please sign in to comment.