mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 05:34:15 +00:00
Fix code example: NSNumber should be marked nonnull
for compatibility with Android
Summary: I was following the Native Modules guide for iOS, when I noticed this error in the example code: > Argument 2 (NSNumber) of CalendarManager.addEvent has unspecified nullability but React requires that all NSNumber arguments are explicitly marked as `nonnull` to ensure compatibility with Android. Marking the parameter NSNumber type as `nonnull` fixes the error in the example. Closes https://github.com/facebook/react-native/pull/9705 Differential Revision: D3804661 Pulled By: JoelMarcey fbshipit-source-id: 92ec8a08ff2a179e4a8935de4cecd7b8d993469b
This commit is contained in:
parent
bcf48e74ae
commit
a02c238464
@ -78,7 +78,7 @@ But it also works with any type that is supported by the `RCTConvert` class (see
|
||||
In our `CalendarManager` example, we need to pass the event date to the native method. We can't send JavaScript Date objects over the bridge, so we need to convert the date to a string or number. We could write our native function like this:
|
||||
|
||||
```objective-c
|
||||
RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location date:(NSNumber *)secondsSinceUnixEpoch)
|
||||
RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location date:(nonnull NSNumber *)secondsSinceUnixEpoch)
|
||||
{
|
||||
NSDate *date = [RCTConvert NSDate:secondsSinceUnixEpoch];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user