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
Albert Chang
10/28/2021, 12:22 AM
Are you rebuilding the list on every recomposition? In that case using
mutableStateListOf
is meaningless. You should use
mutableListOf
instead.
c
Colton Idle
10/28/2021, 12:24 AM
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!