Skip to content

Commit

Permalink
Convert NSNull and nil return value to JS null
Browse files Browse the repository at this point in the history
Summary: When you return null or [NSNull null] from a TurboModule method, we should just return null to JS.

Reviewed By: fkgozali

Differential Revision: D17141170

fbshipit-source-id: a73410b7a4a765750a8dd9c4e904046ffe1c0fc1
  • Loading branch information
RSNara authored and facebook-github-bot committed Sep 7, 2019
1 parent 60601f5 commit 337ec88
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ReactCommon/turbomodule/core/platform/ios/RCTTurboModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,13 @@ void cleanup()
}
}

// VoidKind can't be null
// PromiseKind, and FunctionKind must throw errors always
if (valueKind != VoidKind && valueKind != PromiseKind && valueKind != FunctionKind &&
(result == (id)kCFNull || result == nil)) {
return jsi::Value::null();
}

// TODO: Re-use value conversion logic from existing impl, if possible.
switch (valueKind) {
case VoidKind:
Expand Down

0 comments on commit 337ec88

Please sign in to comment.