Composable which used Components in the arguments are not skippable #598
-
Hello! I saw the sample of the library and noted that Component instances often passed as parameters for composable functions. So i noted that this makes this functions unskippable, which can, in theory, affect performance. There is one my own examples of this case: MyColumn function @Composable
fun MyColumn(myColumnComponent: MyColumnComponent) {
val state = flow.collectAsState()
Logger.d(LOGGER_TAG) { "MyColumn Composable..." }
Column (modifier = Modifier.fillMaxSize().background(Color.Green)) {
Text(text = state.value)
MyText(myColumnComponent.myTextComponent)
}
} MyText function @Composable
fun MyText(myTextComponent: MyTextComponent) {
Logger.d(LOGGER_TAG) { "MyText Composable ..." }
myTextComponent.viewModel // E.g. usage of TextComponent
Text(text = "Some text")
} MyColumnComponent and MyTextComponent that has delegate ComponentContext class MyColumnComponent(
componentContext: ComponentContext
) : ComponentContext by componentContext {
val myTextComponent = MyTextComponent(componentContext)
}
class MyTextComponent(
componentContext: ComponentContext
) : ComponentContext by componentContext {
...
} And finally compose compiles it as unstable type: unstable class MyTextComponent {
unstable var $$delegate_0: ComponentContext
runtime val viewModel: TextViewModel
<runtime stability> = Unstable
} Is it a good idea to mark components with Stable annotation or maybe move delegation to some parent class or maybe I'm missing something? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Thanks for the question. This looks like a duplicate of #581. |
Beta Was this translation helpful? Give feedback.
Thanks for the question. This looks like a duplicate of #581.