Skip to content

Commit

Permalink
JSI: Fix converting funtion to dynamic
Browse files Browse the repository at this point in the history
Apply the same logic as in object properties, return nullptr for a
function object.

Fixes: facebook#27203
  • Loading branch information
saghul committed Feb 12, 2020
1 parent cb80e3b commit daba4ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ReactCommon/jsi/jsi/JSIDynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ folly::dynamic dynamicFromValue(Runtime& runtime, const Value& value) {
}
return ret;
} else if (obj.isFunction(runtime)) {
throw JSError(runtime, "JS Functions are not convertible to dynamic");
// The JSC conversion uses JSON.stringify, which substitutes
// null for a function, so we do the same here. Just dropping
// the pair might also work, but would require more testing.
return nullptr;
} else {
folly::dynamic ret = folly::dynamic::object();
Array names = obj.getPropertyNames(runtime);
Expand Down

1 comment on commit daba4ad

@saghul
Copy link
Member Author

@saghul saghul commented on daba4ad Jul 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, extensively. We no longer use it, however, since due to the refactors in RN we haven’t seen crashes.

Please sign in to comment.