From 1f6eb884bf6a67f9535d2bb5a7a5c279f34a32a5 Mon Sep 17 00:00:00 2001 From: Nick Lefever Date: Mon, 21 Jul 2025 05:02:18 -0700 Subject: [PATCH] Fix modal crash on create with initial props (#52729) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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 --- .../com/facebook/react/views/modal/ReactModalHostView.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt index c711027d172..1126b992da0 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt @@ -256,8 +256,13 @@ public class ReactModalHostView(context: ThemedReactContext) : if (createNewDialog) { dismiss() } else { - updateProperties() - return + // With Props 2.0 the view creation could include initial props. This means the dialog might + // still have to be created before the properties can be set. We only update properties if the + // dialog was already initialized. + dialog?.let { + updateProperties() + return + } } // Reset the flag since we are going to create a new dialog