<@UHAJKUSTU> I have a component with stack navigat...
# decompose
e
@Arkadii Ivanov I have a component with stack navigation, and one of child components (“profile”) also has a stack navigation inside. If I put logging inside the compose function under the
Children
block in the ProfileRoot function and change the navigation (once) from “Profile” to “Replace Selfie” I get a lot of calls and the most weird part is that the children alternate. I tried to find a source of this problem, but with no luck. Do you have any idea why it may happen? (logs in the thread)
Copy code
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = Profile
REMEMBER profile child = ReplaceSelfie
REMEMBER profile child = ReplaceSelfie
Copy code
ErrorHandlingBox(
        modifier = modifier.fillMaxSize(),
        errors = profileRootComponent.oneTimeEvents
    ) {
        Children(
            stack = profileRootComponent.childStack,
            animation = stackAnimation(fade() + scale()),
        ) { createdChild ->
            log("REMEMBER profile child = ${createdChild.instance::class.simpleName}")
these are logs from just a single navigation change from Profile to ReplaceSelfie
a
I think you are experiencing re-compositions while screen transitions are playing. This is completely normal and expected, and Compose should be handling this just fine.
e
if I put also logs into the component itself it is called only once:
Copy code
init {
        stack.subscribe {
            log("REMEMBER Component stack = ${it.active.instance::class.simpleName}")
        }
    }
The main concern is not regarding amount of calls, but about having Profile and ReplaceSelfie alternating
This is normal I guess, both screens are being animated and recomposed frequently.
e
I think you are right. Thank you! I indeed was able to fix my bug by putting the code, which I was not expected to be called into
LaunchedEffect
. I didn’t realise that the sequence of recomposition calls could be so weird.
a
Yeah! Composables should be side effect free.