Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android ComposeView, Composable is gone upon returning to Screen from stack #2098

Open
emitchel opened this issue Apr 7, 2024 · 2 comments
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android

Comments

@emitchel
Copy link

emitchel commented Apr 7, 2024

Description

tldr; Jetpack ComposeViews do not maintain state or recompose upon returning to a Screen with a ComposeView driving a component of the Screen.

Suppose you have three screens, screens A, B and C

Screen B has a View that links to a ComposeView(..) from Android
Navigating to Screen C, then returning to Screen B, the ComposeView driven component is gone

According to this issue tracker, https://issuetracker.google.com/issues/284424175, the issue lies within how ScreenFragment recycles the views
https://github.com/software-mansion/react-native-screens/blob/main/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt#L307-L321

react-native-community/discussions-and-proposals#446 (comment)

Project to repro (thanks to @thevoiceless) - https://github.com/thevoiceless/RN-Compose-Playground

problematic-compose-view.mov

Steps to reproduce

  1. Use a SimpleViewManager to wrap a ComposeView
  2. Build the ComposeView with a simple Text(..)
  3. But that ComposeView in Screen A
  4. Navigate to Screen B
  5. Navigate BACK to Screen A
  6. Notice that the ComposeView is gone but the wrapper of the view itself is still in the hierarchy

Snack or a link to a repository

https://github.com/thevoiceless/RN-Compose-Playground

Screens version

3.21.0

React Native version

0.73.5

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Missing repro This issue need minimum repro scenario labels Apr 7, 2024
Copy link

github-actions bot commented Apr 7, 2024

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@tboba
Copy link
Member

tboba commented Apr 8, 2024

Hi @emitchel, thanks for filling this issue!
Yeah, using Jetpack Compose along React Native Screens have already been heavily discussed in our internal Screens Team 😄 We've got this task of supporting Jetpack Compose on our agenda. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android
Projects
None yet
Development

No branches or pull requests

2 participants