Open vishalbhimporwala opened 4 days ago
Thanks for reporting! This looks like a bug. From the top of my head, retainedComponent
was supposed to be the only one in an Activity. However, there is the key
argument there, which probably there for a reason. I will try fixing it or provides updates here.
For now, please use the following approach.
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val (root, dash) = retainedComponent {
RootComponent(it.childContext("root")) to DashBoardRootComponent(it.childContext("dash"))
}
setContent {
App(rootF, dashF)
}
}
}
Also regarding the desktop version, please make sure you are following the docs. Usually, components should be created outside of Compose.
Thank you so much sir,
class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val (rootComponent, dashBoardRootComponent) = retainedComponent { RootComponent(it.childContext("root")) to DashBoardRootComponent(it.childContext("dash")) } setContent { App(rootComponent, dashBoardRootComponent) } }
}It will work as I need it to.
As per your suggestion I updated my desktop entry point code.
fun main() = application { Window( onCloseRequest = ::exitApplication, title = "neon-music-kmp", ) { val root = runOnUiThread { RootComponent( componentContext = DefaultComponentContext(LifecycleRegistry()) ) } val dashBoardRoot = runOnUiThread { DashBoardRootComponent( componentContext = DefaultComponentContext(LifecycleRegistry()) ) } App(root, dashBoardRoot) } }
Now it's working fine. Thanks again.
On Fri, Nov 8, 2024 at 3:57 PM Arkadii Ivanov @.***> wrote:
Thanks for reporting! This looks like a bug. From the top of my head, retainedComponent was supposed to be the only one in an Activity. However, there is the key argument there, which probably there for a reason. I will try fixing it or provides updates here.
For now, please use the following approach.
class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState)
val (root, dash) = retainedComponent { RootComponent(it.childContext("root")) to DashBoardRootComponent(it.childContext("dash")) } setContent { App(rootF, dashF) } }
}
Also regarding the desktop version, please make sure you are following the docs https://arkivanov.github.io/Decompose/component/overview/#jvmdesktop-with-compose. Usually, components should be created outside of Compose.
— Reply to this email directly, view it on GitHub https://github.com/arkivanov/Decompose/issues/807#issuecomment-2464347088, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHNIYGJ5TJBYFHJD7LYEBW3Z7SGX3AVCNFSM6AAAAABRMXEI6SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRUGM2DOMBYHA . You are receiving this because you authored the thread.Message ID: @.***>
-- - VISHAL BHIMPORWALA
Here my RootComponent class
Here my DashBoardRootComponent class
My App Component
For Android MainActivity 1st Try
Logcat :
For Android MainActivity 2nd Try from chatGpt reference
Logcat :
I am facing this issue only for android
Do code for desktop also but it will working fine. Here Desktop entry point
Can any one explain me where i need to give unique key for android retainedComponent ? Tell me if i am wrong in anything.