easy5 pts · first answer countsandroidjetpack-composestate
Counter jumps back to zero
The count sometimes jumps back to 0, for example when the parent screen recomposes. Why?
@Composable
fun Counter() {
var count by mutableStateOf(0)
Button(onClick = { count++ }) {
Text("Count: $count")
}
}Discussion 0
Join free to post in the discussion.
Related questions
- Android activity start orderMobile App Developer
- StatelessWidget or StatefulWidgetMobile App Developer
- Compose modifier orderMobile App Developer
- What AndroidManifest.xml is forMobile App Developer
- Sharing text to any appMobile App Developer
- Play Console rejects the build versionMobile App Developer
- lateinit or by lazyMobile App Developer
- A chain of safe callsMobile App Developer