From e1cd02718f849eab8330b91eb5a383dbc1f1c6e4 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Thu, 8 Feb 2024 12:48:38 +0000 Subject: [PATCH] fix(Android): change context while running `runOnUiQueueThread` on 0.73 with Bridgeless (#2022) ## Description I've been discussing this change with @WoLewicki. The problem here is that you're attempting to call `runOnUiQueueThread` on the wrong Context. ## Changes Changes the `Context` where we invoke `.runOnUiQueueThread` ## Test code and steps to reproduce Tested against this reproducer: https://github.com/cortinico/reproducer-rnscreens-bridgeless ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes Co-authored-by: tboba --- .../src/main/java/com/swmansion/rnscreens/ScreenContainer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt index ac45255e86..7fa727671c 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt @@ -318,7 +318,7 @@ open class ScreenContainer(context: Context?) : ViewGroup(context) { // The exception to this rule is `updateImmediately` which is triggered by actions // not connected to React view hierarchy changes, but rather internal events needsUpdate = true - (context as? ReactContext)?.runOnUiQueueThread { + (context.applicationContext as? ReactContext)?.runOnUiQueueThread { // We schedule the update here because LayoutAnimations of `react-native-reanimated` // sometimes attach/detach screens after the layout block of `ScreensShadowNode` has // already run, and we want to update the container then too. In the other cases,