Why does navigation composable call twice?

Viewed 298

Why does navigation composable call twice? If I set a breakpoint on the Text I will get two stops when the app runs. Thank you for your answers.

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            val navController = rememberNavController()
            var i: Int = 0
            NavHost(navController = navController, startDestination = "s1") {
                composable("s1") {
                    i++
                    Text("$i")

                }
            }
        }
    }
}
0 Answers
Related