mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ca3c8b7a7d
Summary: Currently `RCTBridgingToOptionalBool` and `RCTBridgingToOptionalDouble` will crash if passed an `NSNull` value. This diff changes these functions to instead treat it as equivalent to a missing value. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D18532044 fbshipit-source-id: fa822dcacb49697dd8a4f7b579bcfc029e0cdf41
46 lines
877 B
Plaintext
46 lines
877 B
Plaintext
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import "RCTConvertHelpers.h"
|
|
|
|
#import <React/RCTConvert.h>
|
|
|
|
bool RCTBridgingToBool(id value)
|
|
{
|
|
return [RCTConvert BOOL:value] ? true : false;
|
|
}
|
|
|
|
folly::Optional<bool> RCTBridgingToOptionalBool(id value)
|
|
{
|
|
if (!RCTNilIfNull(value)) {
|
|
return {};
|
|
}
|
|
return RCTBridgingToBool(value);
|
|
}
|
|
|
|
NSString *RCTBridgingToString(id value)
|
|
{
|
|
return [RCTConvert NSString:value];
|
|
}
|
|
|
|
folly::Optional<double> RCTBridgingToOptionalDouble(id value)
|
|
{
|
|
if (!RCTNilIfNull(value)) {
|
|
return {};
|
|
}
|
|
return RCTBridgingToDouble(value);
|
|
}
|
|
|
|
double RCTBridgingToDouble(id value)
|
|
{
|
|
return [RCTConvert double:value];
|
|
}
|
|
|
|
NSArray *RCTBridgingToArray(id value) {
|
|
return [RCTConvert NSArray:value];
|
|
}
|