I have a composable, that draws other composables ...
# compose
c
I have a composable, that draws other composables from a list as seen here:
Copy code
val myListOfComposables = mutableStateListOf<@Composable () -> Unit>()
This code triggers a lint warning/error that I should remember it. When I remember it, then I get duplication, seemingly every time it recomposes.
Copy code
val myListOfComposables = remember { mutableStateListOf<@Composable () -> Unit>() }
Is the lint issue wrong? Or am I doing something wrong?
a
Are you rebuilding the list on every recomposition? In that case using
mutableStateListOf
is meaningless. You should use
mutableListOf
instead.
c
Hm. That makes sense. I'm not in front of my computer. But yeah. Basically my composable builds a list of composables at the top. And then it loops through all of them and shows them. I think having it be a stateList was probably a mistake and I should just have it be a list. I'll try it out later tonight. Thanks!
👍 1