Skip to content

Commit a4d2f20

Browse files
janicduplessisoss sync
authored andcommitted
Fix a crash in RCTAsyncLocalStorage when the value is not a string.
Summary: When you forget to pass the value parameter to AsyncStorage.setItem the entire app would crash instead of showing a useful error message. The problem was that the error function used in the file expected a dictionary but was passed the value of the key which caused the crash. Closes facebook#535 Github Author: Janic Duplessis <[email protected]> Test Plan: Imported from GitHub, without a `Test Plan:` line.
1 parent 8ecf397 commit a4d2f20

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

React/Modules/RCTAsyncLocalStorage.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ - (id)_writeEntry:(NSArray *)entry
157157
return RCTMakeAndLogError(@"Entries must be arrays of the form [key: string, value: string], got: ", entry, nil);
158158
}
159159
if (![entry[1] isKindOfClass:[NSString class]]) {
160-
return RCTMakeAndLogError(@"Values must be strings, got: ", entry[1], entry[0]);
160+
return RCTMakeAndLogError(@"Values must be strings, got: ", entry[1], @{@"key": entry[0]});
161161
}
162162
NSString *key = entry[0];
163163
id errorOut = RCTErrorForKey(key);

0 commit comments

Comments
 (0)