Skip to content

Commit 619d5df

Browse files
cipolleschifacebook-github-bot
authored andcommittedMar 7, 2025··
Handle null params in the Interop TM layer (#49873)
Summary: Pull Request resolved: #49873 In the old architecture, when we were passing a `null` value as a parameter in a function that accepted nullable parameter, the null value was mapped to `nil` on iOS. After my changes in [d423679](d423679), in the New Architecture, through the interop layer, legacy modules were receiving an `NSNull` object instead of nil. This was breaking those modules which started crashing or observing undesired behavior. This change fixes the issue by making sure that, in those cases, a `nil` value is passed. Note that nested objects in the old architecture were correctly receiving NSNull, so nested objects were behaving correctly already. ## Changelog: [iOS][Fixed] - Properly pass `nil` for nullable parameters instead of `NSNull` for legacy modules Reviewed By: javache Differential Revision: D70723460 fbshipit-source-id: 384f48b6dbb3f54c369b31b6d2ee06069fa3591c
1 parent d4c3264 commit 619d5df

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm

+9
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,15 @@ T RCTConvertTo(SEL selector, id json)
446446

447447
if (objCArgType == @encode(id)) {
448448
id arg = RCTConvertTo<id>(selector, objCArg);
449+
450+
// Handle the special case where there is an argument and it must be nil
451+
// Without this check, the JS side will receive an object.
452+
// See: discussion at
453+
// https://github.com/facebook/react-native/pull/49250#issuecomment-2668465893
454+
if (arg == [NSNull null]) {
455+
return;
456+
}
457+
449458
if (arg) {
450459
[retainedObjectsForInvocation addObject:arg];
451460
}

0 commit comments

Comments
 (0)
Please sign in to comment.