View isn't updated after recomposition
Jasperav opened this issue · comments
I have seen it in more complex applications, but this is the easiest reproduction view:
@Composable
fun ClusterItemConversation() {
val x = remember { mutableIntStateOf(0) }
LaunchedEffect(key1 = Unit) {
// This just delays the execution
dispatchToMainThread(2000) {
x.value += 1
log { "Updated" }
}
}
Column(verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally) {
Text(text = x.value.toString())
}
}
// Some map code...
Clustering(items = clusterItems, clusterItemContent = { ci ->
ClusterItemConversation()
})
In the logging I can observe that Updated
is there, but the view isn't updated at all, the text remains 0. The view is out of sync.
i think i have a similar issue.
the clusterItem is depending on state that is updated but using the clustering we're not able to specify a key
like in the MarkerComposable()
how are we supposed to define such state objects using a cluster?
i created a sample for my case here: main...cwsiteplan:android-maps-compose:bug/cluster-item-update
i do have a mutable state that holds the ID of the selected marker.
but the clusterItemContent
does not get recomposed, even though read state values do change.
@Composable
fun CustomRendererClustering(items: List<MyItem>, selectedId: String) {
...
clusterItemContent = {
CircleContent(
modifier = Modifier.size(20.dp),
text = "",
color = if (it.id == selectedId) Color.Red else Color.Green,
)
},
...
}
Same issue here. Any work around?
Any update on this?
Also looking for a solution for this please. Exact same issue as above, I have an isSelected boolean that is getting updated, but the view isn't getting recomposed.
Just encountered the same issue here. Can we at least have a workaround for the recomposition, like MarkerComposable
did?
I also have this issue, I would like to update the clustered marker composables based on user interaction!
I had the same issue with maps-compose-utils version 4.3.2. Using version 4.2.0 works fine.