From df17ebfcfaaf2cf5984e836bdb70ccf8d9f66307 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 24 Jun 2019 07:10:23 -0700 Subject: [PATCH] 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 --- React/Base/RCTConvert.m | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index cd2feb8ad0c..0a6031a9141 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -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];