https://kotlinlang.org logo
#compose
Title
# compose
z

zhagnfei

08/20/2021, 2:51 AM
i want render diff view with data but when use state it not change like this:
Copy code
val state: MutableList<String>? by imageList.observeAsState(mutableListOf())
if (state.isNullOrEmpty()) {
    feedbackPlaceView(addImgClick)
} else {
    state?.forEachIndexed { listIndex, s ->
z

Zach Klippenstein (he/him) [MOD]

08/20/2021, 4:24 AM
It’s usually a red flag if you have a MutableList inside a state object. Are you mutating the list instance itself?
z

zhagnfei

08/20/2021, 6:32 AM
if i want update view with data how to do?
i know,must use SnapshotStateList
z

Zach Klippenstein (he/him) [MOD]

08/20/2021, 10:05 AM
Either use that, or use an immutable list with a MutableState