Skip to content

The same screen will be accidentally reorganized when it returns #547

@suzhelan

Description

@suzhelan

The same screen will be accidentally reorganized when it returns

The execution process is similar to the following:
TestScreen->TestScreen->TestScreen

This is the log record

start ->TestScreen Reorganization:0
enter -> TestScreen Reorganization:1
enter -> TestScreen Reorganization:2
back -> TestScreen Reorganization:1
back -> TestScreen Reorganization:0

It can be seen that it is accidentally reorganized when returned, and no method can avoid it, including extracting functions, extracting State as remember, etc.

Thie my code

class TestScreen(
    private val count : Int =0
) : Screen {
    override val key: ScreenKey = "TestScreen#$count"
    @Composable
    override fun Content() {
        val navigator = LocalNavigator.currentOrThrow
        CommonComposeUI<VideoPlayerViewModel> {
            Column {
                LogUtils.d("TestScreen Reorganization:$count")
                Text(
                    text = "count: $count"
                )
                Button(
                    onClick = {
                        navigator.push(TestScreen(count + 1))
                    }
                ) {
                    Text("next")
                }
            }

        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions