I have this code for my navigation bar. Is this go...
# compose-android
z
I have this code for my navigation bar. Is this gonna cause issues with unintended recomposition?
Copy code
NavigationBar {
                        BaseDestination.values().forEach { destination ->
                            NavigationBarItem(
                                selected = navController.currentDestination == destination,
                                icon = { Icon(destination.icon, null) },
                                label = { Text(stringResource(destination.label)) },
                                onClick = { navController.switchTo(destination) }
                            )
                        }
                    }
s
What kind of issues are you concerned about? what do you feel is wrong with what you’ve written here? Have you experienced some issue already or just guessing?
e
One issue I see here is that you recreate the enum array on every recomposition by calling
values()
. Not a big issue, just something to note about how Enum.values works