z

    zhagnfei

    1 year ago
    i want render diff view with data but when use state it not change like this:
    val state: MutableList<String>? by imageList.observeAsState(mutableListOf())
    if (state.isNullOrEmpty()) {
        feedbackPlaceView(addImgClick)
    } else {
        state?.forEachIndexed { listIndex, s ->
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    It’s usually a red flag if you have a MutableList inside a state object. Are you mutating the list instance itself?
    z

    zhagnfei

    1 year ago
    if i want update view with data how to do?
    i know,must use SnapshotStateList
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    Either use that, or use an immutable list with a MutableState