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
Child gets recomposed more than once at startup in Compose Desktop #56
Comments
Hello. I didn't deep dive into the issue yet. But from the first sight, we should never rely on how much time recompositions should happen. Ideally components and their contexts should be created outside of Composables functions. E.g. the Root component should be created in the main function, before Compose If this is not possible for some reason, then there is The navigation should be always performed as side effects, never from the composition calls. |
I believe this should be mentioned in the documentation, I will add. Thanks for raising. |
This method seems to have stopped the crashes which were caused by my ViewModel being created more than once rapidly and causing SQLDelight to crash my app due to conflicting transactions. But the navigation to About screen issue still persists. I don't know why my onAboutClicked() event is not propagating to the respective component inside RootComponent implementation despite other similar events being received. Is there something else I am missing? Screen_Recording.6.mp4 |
Do you want to apply my suggestions? Components and contexts should not be created directly in composable functions. Either in the main app or in |
I understand what you mean. All of my components are created outside of the composables just like in the documentations but my current issue is with the single click (onAboutClick) for navigation to one route (About Screen) that does not activate no matter what I try. Maybe I should open a new issue since it's not directly to recomposition. Thank you for your time. I'll close this issue since I've already moved component creation outiside of the |
Let's keep this issue open for a while, I want to add this to the documentation. As far I see by the link provided above, components are created inside Composable functions. E.g. in the App function. |
Already fixed that as per your recommendation. It's already moved to the main function that's why it not longer crashes like before. See Main.kt in the new commit |
Thanks, I will try to check the project today or tomorrow. |
Oh wow. Don't know how I missed that. Thanks for your timel |
I have 2 problems at the moment.
You can see here on the first screenshot that at the launch there are multiple calls to same thing (related to the Home Screen):
But after you navigate to something like a Settings Screen. You only see one call for each. Even when you pop back to the Home screen the home screen composable will be called only once this time:
I am using Decompose version: 0.5.2. Github link to the navigation and ui part of the app in question is this: https://github.com/Thinkrchive/Thinkrchive-Multiplatform/tree/main/desktopApp/src/jvmMain/kotlin/work/racka/thinkrchive/v2/desktop/ui
The navigation folder contains RootComponent and it's implementations.
The screen folder contains each screen composable with it component Interface and Implementation.
I followed the official guide for using compose-extensions.
When I click the About button the event is not propagated from the comoposable to the component creation inside my NavHostComponent
What's weird is that every other call like for settingsScreen or donateScreen work as expected just the aboutScreen call that has issues.
Also using crossfade() or crossfadeScale() crashes the app or refuses any navigation calls.
The text was updated successfully, but these errors were encountered: