Back out "[react-native][PR] [iOS] Add convert compatible of NSString for bridge message data"

Summary:
Original commit changeset: 4849a8e94141

# Problem:
This diff caused https://github.com/facebook/react-native/issues/25339.
It was converting non string values to strings whenever the conversion was available.

The original problem that this diff was trying to solve is described here -> https://twitter.com/estevao_lucas/status/1117572702083190785?s=215

# Solution introduced by this diff
This diff introduced a conversion. So for any value that was meant to be string but wasn't we would attempt to convert it. Which is not always wanted.

# Solution for problem in the twitter
I think we should improve the error message if incorrect type is being passed as a prop. However this isn't a problem if views are Flow typed.

Reviewed By: cpojer

Differential Revision: D15964298

fbshipit-source-id: 3d027a378561b87e7a9e89fc5e39dc6f359d8d22
This commit is contained in:
Samuel Susla
2019-06-24 07:13:46 -07:00
committed by Facebook Github Bot
parent 004a90b131
commit df17ebfcfa
+1 -10
View File
@@ -53,21 +53,12 @@ RCT_NUMBER_CONVERTER(NSUInteger, unsignedIntegerValue)
RCT_JSON_CONVERTER(NSArray)
RCT_JSON_CONVERTER(NSDictionary)
RCT_JSON_CONVERTER(NSString)
RCT_JSON_CONVERTER(NSNumber)
RCT_CUSTOM_CONVERTER(NSSet *, NSSet, [NSSet setWithArray:json])
RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncoding])
+ (NSString *)NSString:(id)json
{
if ([json isKindOfClass:NSString.class]) {
return json;
} else if (json && json != (id)kCFNull) {
return [NSString stringWithFormat:@"%@",json];
}
return nil;
}
+ (NSIndexSet *)NSIndexSet:(id)json
{
json = [self NSNumberArray:json];