Hey! Would it be safe to call `retainedComponent` ...
# decompose
n
Hey! Would it be safe to call
retainedComponent
in the root function of a Compose Multiplatform app?
Copy code
@Composable
fun App() {
    val rootComponent = remember { retainedComponent{ context -> DefaultRootComponent(context) } }
}
Goal: To have a single entry point for all targets.
a
Nope, not safe. On configuration change the remember {} block will run again.
👍 1
n
So
retainedComponent
should always be called in the main function of each platform, right?
a
It's only available on Android, since the concept only exists on Android.
It's designed to be called from onCreate callback
n
Ah, that makes sense. I was searching for a way to instantiate the Root component in the common code.
a
Yeah, it's better to instantiate the root component outside of Compose.
👍 1
n
Thanks, Arkadii 🙂
👍 1