Created
July 29, 2023 00:11
-
-
Save phatnhse/ffa167de5f073936c0bbae619f9506c0 to your computer and use it in GitHub Desktop.
recompose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Sample() { | |
var button1 by remember { mutableStateOf("button 1") } | |
var button2 by remember { mutableStateOf("button 2") } | |
Column(horizontalAlignment = Alignment.CenterHorizontally) { | |
// Recomposes when `button1` changes, but not when button2 changes | |
Button(onClick = { button1 += "1" }) { Text(text = button1) } | |
Spacer(modifier = Modifier.height(8.dp)) | |
// Recomposes when `button2` changes, but not when button1 changes | |
Button(onClick = { button2 += "2" }) { Text(text = button2) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment