t

    tad

    1 year ago
    Should
    rememberSaveableStateHolder()
    restore the scroll state of a
    LazyColumn
    in a child composable?
    Code:
    @Composable
    fun HomeContent(
        currentScreen: Screen,
        modifier: Modifier = Modifier,
        content: @Composable (Screen) -> Unit
    ) {
        val stateHolder = rememberSaveableStateHolder()
    
        Crossfade(targetState = currentScreen) { screen ->
            Box(modifier) {
                stateHolder.SaveableStateProvider(screen.key) {
                    content(screen)
                }
            }
        }
    }
    Switching screens and back jumps the list to the top every time, although I'm also using
    paging-compose
    which may affect this
    (In the snippet,
    content(screen)
    runs a
    LazyColumn
    in one of the screens)
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    t

    tad

    1 year ago
    ah, thanks!