sample1Binding.composeView.setContent {
var text by remember { mutableStateOf("before nav") }
Button(onClick = {
findNavController().navigate(R.id.action_sample1_to_sample2)
text = "after nav"
}) {
Text(text)
}
}
I have a fragment with a Button composable in it. on clicking the button, a navigation should occur then the value of text should change. What actually happens is that text visibly changes, then navigation occurs.
Why does this happen and is there a way around this?