Skip to content

Commit bbf7004

Browse files
Bartlomiej Bloniarzmeta-codesync[bot]
authored andcommitted
Add null check for ViewState in SurfaceMountingManager::updateProps (#56147)
Summary: Pull Request resolved: #56147 I saw that in D95793355 a null check was added for the view state in updateLayout. A similar issue can happen (and has been happening with Reanimated) with the updateProps method, so this diff makes it consistent with the other codepaths. ## Changelog: [General] [Changed] - use getNullableViewState in SurfaceMountingManager::updateProps and log a soft exception instead Reviewed By: javache Differential Revision: D97087668 fbshipit-source-id: e69da89e2f0277714d242ed6ef5c9050cdc03dbc
1 parent 1fdd167 commit bbf7004

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,14 @@ internal constructor(
608608
return
609609
}
610610

611-
val viewState = getViewState(reactTag)
611+
val viewState = getNullableViewState(reactTag)
612+
if (viewState == null) {
613+
ReactSoftExceptionLogger.logSoftException(
614+
ReactSoftExceptionLogger.Categories.SURFACE_MOUNTING_MANAGER_MISSING_VIEWSTATE,
615+
ReactNoCrashSoftException("Unable to find viewState for tag $reactTag for updateProps"),
616+
)
617+
return
618+
}
612619

613620
if (
614621
ReactNativeFeatureFlags.overrideBySynchronousMountPropsAtMountingAndroid() &&
@@ -624,7 +631,7 @@ internal constructor(
624631
viewState.currentProps = ReactStylesDiffMap(props)
625632
}
626633

627-
val view: View = checkNotNull(viewState.view) { "Unable to find view for tag [$reactTag]" }
634+
val view: View = viewState.view ?: return
628635
checkNotNull(viewState.viewManager).updateProperties(view, viewState.currentProps)
629636
}
630637

0 commit comments

Comments
 (0)