I don’t see a separate channel for decompose, so I’ll ask my question here: I have a Component that has several instances of the same sub-component, which will get rendered in a Column. Each one has fairly complex logic and is independent from the others, so I’m thinking one Component class, and an array of instances. I can see here that I should use childComponent with a unique key. Is there a good way to create an array of childComponent built in, or should I have the keys be Bar0, Bar1, Bar2, etc?
x
xxfast
05/19/2022, 10:26 PM
its about time we have a seperate channel for decompose @Arkadii Ivanov 😅
❤️ 1
a
Arkadii Ivanov
05/19/2022, 10:28 PM
Yeah, there is no channel. Some people are using #mvikotlin for this. But I will think about a separate channel.
As mentioned in the docs, there are two ways of creating child components - via
Router
and manually. In the latter case, they should have unique keys.
So something like this should work (off the top of my head):
Copy code
val children = List(10) { index ->
MyComponent(
context = childContext(key = "Child$index"),
// Other dependencies here
)
}