Skip to content

Commit 1f6eb88

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Fix modal crash on create with initial props (#52729)
Summary: Pull Request resolved: #52729 The Modal view creation contains initial properties when using Props 2.0. This diff adds support for Modal view creations having initial properties by allowing the `updateProperties` fast path only if the dialog is already initialized. Without the change, the fast path gets called before the dialog could be initialized which leads to throwing an exception when the dialog is being checked to see if it is initialized. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D78638902 fbshipit-source-id: 61ad007b82867fa8b35648e3d8c930ee0e86c80d
1 parent a0a77f7 commit 1f6eb88

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,13 @@ public class ReactModalHostView(context: ThemedReactContext) :
256256
if (createNewDialog) {
257257
dismiss()
258258
} else {
259-
updateProperties()
260-
return
259+
// With Props 2.0 the view creation could include initial props. This means the dialog might
260+
// still have to be created before the properties can be set. We only update properties if the
261+
// dialog was already initialized.
262+
dialog?.let {
263+
updateProperties()
264+
return
265+
}
261266
}
262267

263268
// Reset the flag since we are going to create a new dialog

0 commit comments

Comments
 (0)