'How to stop Jetpack Compose Navigation executing composable twice per click and why

I have created a Jetpack compose navigation as follows:

val navController = rememberNavController()

Scaffold(
    bottomBar = { /* BottomBar code here */ }
){ innerPadding ->

    NavHost(
         navController = navController,
         startDestination = "navigation",
         modifier = Modifier.padding(innerPadding)
    ){

        composable("home") { Log.d(TAG, "Show home screen") }

        composable("account") { Log.d(TAG, "Show account screen") }

        composable("settings") { Log.d(TAG, "Show settings screen") }

    }

}

My problem is when ever I click on a nav item, the log message on the composable() function is printed twice per click in logcat. I may have missed something on the documentation. Why is this happening & how can I fix it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source