You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix crash on ReactInstance due to null returned for getViewManagerNames (#52035)
Summary:
Pull Request resolved: #52035Fixes#52014
Some OSS library is still returning null for `getViewManagerNames` especially if they're
implementing the `ViewManagerOnDemandReactPackage` in Java.
I'm adding a try-catch here so that we prevent the NPE for those scenarios.
Changelog:
[Android] [Fixed] - Fix crash on ReactInstance due to null returned for getViewManagerNames
Reviewed By: javache
Differential Revision: D76723826
fbshipit-source-id: cc159dee389257c6877b03a67840a45ee5bec165
@@ -544,7 +545,18 @@ internal class ReactInstance(
544
545
for (reactPackage in reactPackages) {
545
546
if (reactPackage isViewManagerOnDemandReactPackage) {
546
547
val names = reactPackage.getViewManagerNames(context)
547
-
uniqueNames.addAll(names)
548
+
// We need to null check here because some Java implementation of the
549
+
// `ViewManagerOnDemandReactPackage` interface could still return null even
550
+
// if the method is marked as returning a non-nullable collection in Kotlin.
551
+
// See https://github.com/facebook/react-native/issues/52014
552
+
@Suppress("SENSELESS_COMPARISON")
553
+
if (names ==null) {
554
+
RNLog.w(
555
+
context,
556
+
"The ReactPackage called: `${reactPackage.javaClass.simpleName}` is returning null for getViewManagerNames(). This is violating the signature of the method. That method should be updated to return an empty collection.")
0 commit comments