Skip to content

Commit 15434c7

Browse files
Alexander Kawrykowfacebook-github-bot
Alexander Kawrykow
authored andcommitted
Guard against null values in object parameters for bridged methods
Summary: Handles the case when a value in an object parameter of a turbo module spec is null (even if the type is nullable). For example, given: ``` export interface Spec extends TurboModule { +myFunc: ({| foo: ?string, |}) => void; } ``` and calling `NativeModule.myFunc({foo: null})`, we see an error like: ``` JSON value '<null>' of type NSNull cannot be converted to NSString ``` Guarding against this by converting NSNull's to nils ## Changelog: [iOS] [Fixed] - Fix crash when passing null value in object parameter of bridged method Reviewed By: fkgozali Differential Revision: D20591590 fbshipit-source-id: fdb90f34131427a235f2e3c99147bf1e6a9c6732
1 parent 8721ee0 commit 15434c7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Libraries/TypeSafety/RCTConvertHelpers.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bool RCTBridgingToBool(id value)
2424

2525
NSString *RCTBridgingToString(id value)
2626
{
27-
return [RCTConvert NSString:value];
27+
return [RCTConvert NSString:RCTNilIfNull(value)];
2828
}
2929

3030
folly::Optional<double> RCTBridgingToOptionalDouble(id value)

0 commit comments

Comments
 (0)