Skip to content

Commit

Permalink
fix(Android): use reactApplicationContext in onScreenChanged (softwar…
Browse files Browse the repository at this point in the history
…e-mansion#2046)

Potential fix for changes from software-mansion#2022, see comment software-mansion#2022 (comment)
  • Loading branch information
WoLewicki authored and ja1ns committed Oct 9, 2024
1 parent 2de8ac5 commit 1a529be
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.facebook.react.ReactRootView
import com.facebook.react.bridge.ReactContext
import com.facebook.react.modules.core.ChoreographerCompat
import com.facebook.react.modules.core.ReactChoreographer
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.UIManagerHelper
import com.swmansion.rnscreens.Screen.ActivityState
import com.swmansion.rnscreens.events.ScreenDismissedEvent
Expand Down Expand Up @@ -318,14 +319,15 @@ 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.applicationContext as? ReactContext)?.runOnUiQueueThread {
(context as ThemedReactContext).reactApplicationContext.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,
// this code will do nothing since it will run after the UIBlock when `mNeedUpdate`
// will already be false.
performUpdates()
}

}

protected fun performUpdatesNow() {
Expand Down

0 comments on commit 1a529be

Please sign in to comment.