Thread
#compose
    izyaboi

    izyaboi

    1 year ago
    I have one question. how can i handle rember state on bottomnavigation switch. I have a home screen with a composable that has a
    var isPlayingState by remember { mutableStateOf(false) }
    and set it in clickable (Box)
    isPlayingState = if (player.isPlaying) {
        player.pause()
        false
    } else {
        player.play()
        true
    }
    If i navigate to the second tab and navigate back the value ist false and not the last state i set ?why?
    Desmond Teo

    Desmond Teo

    1 year ago
    it is likely that the declared variable is no longer in composition when you navigate to the other tab. one way to resolve this is to hoist the isPlayingState out of the scaffold of your content
    j

    jaqxues

    1 year ago
    Or, depending on how ViewModels are scoped, put the state into the viewModel
    izyaboi

    izyaboi

    1 year ago
    mhmh
    i dont set the value in a viewmodel right now all i do is call a home composable with a player composable and set the remember value and the click event .in my scafold