Skip to content

Instantly share code, notes, and snippets.

@mddanishansari
Created May 5, 2023 15:44
Show Gist options
  • Save mddanishansari/65fed3b80452d5ecff0ee91bd39fbb4b to your computer and use it in GitHub Desktop.
Save mddanishansari/65fed3b80452d5ecff0ee91bd39fbb4b to your computer and use it in GitHub Desktop.
@Composable
fun ListWithJustColumn() {
Column {
(1..5).toList().forEach { number ->
var text by remember { mutableStateOf("$number: ") }
println(text) // This log is printed for all items even if it is changed for just one time
OutlinedTextField(value = text, onValueChange = { text = it })
}
}
}
@Composable
fun ListWithLazyColumn() {
LazyColumn {
items(5) { number ->
var text by remember { mutableStateOf("$number: ") }
println(text) // This log is printed for item only which is changed
OutlinedTextField(value = text, onValueChange = { text = it })
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment