mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Check for nullability of [NSString UTF8String]
Summary: Changelog: [internal] [NSString UTF8String] is nullable. Therefore, we need to check if it isn't nil before passing it to std::string constructor which crashes if it's nil. Reviewed By: shergin Differential Revision: D23572652 fbshipit-source-id: 59e7f5e918b2e5c69333bfb687371f856555d8e0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4d920fe7c9
commit
4b95bb2f84
@@ -32,7 +32,7 @@ inline NSString *_Nullable RCTNSStringFromStringNilIfEmpty(
|
||||
|
||||
inline std::string RCTStringFromNSString(NSString *string)
|
||||
{
|
||||
return string ? std::string([string UTF8String]) : "";
|
||||
return std::string{string.UTF8String ?: ""};
|
||||
}
|
||||
|
||||
inline UIColor *_Nullable RCTUIColorFromSharedColor(const facebook::react::SharedColor &sharedColor)
|
||||
|
||||
Reference in New Issue
Block a user