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
@@ -542,7 +543,18 @@ internal class ReactInstance(
542
543
for (reactPackage in reactPackages) {
543
544
if (reactPackage isViewManagerOnDemandReactPackage) {
544
545
val names = reactPackage.getViewManagerNames(context)
545
-
uniqueNames.addAll(names)
546
+
// We need to null check here because some Java implementation of the
547
+
// `ViewManagerOnDemandReactPackage` interface could still return null even
548
+
// if the method is marked as returning a non-nullable collection in Kotlin.
549
+
// See https://github.com/facebook/react-native/issues/52014
550
+
@Suppress("SENSELESS_COMPARISON")
551
+
if (names ==null) {
552
+
RNLog.w(
553
+
context,
554
+
"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