From 8e95b4634784eebe7acbc87113c2d558406c721e Mon Sep 17 00:00:00 2001 From: Yehor Kharchenko Date: Wed, 8 Apr 2026 14:14:37 +0200 Subject: [PATCH 1/2] fix(Android, Stack): dispatch lifecycle events when parent is not a ScreenFragment --- .../src/main/java/com/swmansion/rnscreens/ScreenFragment.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt index 65c6e304da..1584f1f6b4 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt @@ -292,8 +292,10 @@ open class ScreenFragment : // since we subscribe to parent's animation start/end and dispatch events in child from there // check for `isTransitioning` should be enough since the child's animation should take only // 20ms due to always being `StackAnimation.NONE` when nested stack being pushed + // When the parent is not a ScreenFragment (e.g. when RN is loaded inside a ReactFragment + // in a brownfield setup), we always dispatch. Such parents don't participate in screen transitions. val parent = parentFragment - if (parent == null || (parent is ScreenFragment && !parent.isTransitioning)) { + if (parent == null || parent !is ScreenFragment || (parent is ScreenFragment && !parent.isTransitioning)) { // onViewAnimationStart/End is triggered from View#onAnimationStart/End method of the fragment's root // view. We override an appropriate method of the StackFragment's // root view in order to achieve this. From 65aeb5be8c21a57cd4a50c068a1c1532756c90d0 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 15 Apr 2026 17:55:28 +0200 Subject: [PATCH 2/2] Simplify the condition just a bit It's still clear and not redundant --- android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt index 1584f1f6b4..6fcabc3e92 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt @@ -295,7 +295,7 @@ open class ScreenFragment : // When the parent is not a ScreenFragment (e.g. when RN is loaded inside a ReactFragment // in a brownfield setup), we always dispatch. Such parents don't participate in screen transitions. val parent = parentFragment - if (parent == null || parent !is ScreenFragment || (parent is ScreenFragment && !parent.isTransitioning)) { + if (parent == null || parent !is ScreenFragment || !parent.isTransitioning) { // onViewAnimationStart/End is triggered from View#onAnimationStart/End method of the fragment's root // view. We override an appropriate method of the StackFragment's // root view in order to achieve this.