# compose

Timo Drick

01/28/2021, 1:13 PM
I think i found a bug. Not sure. But i do have a modifier that swipes away an element in a list and than removes the item from the list. This modifier remembers the state that the element is removed. Than when i remove the element from the list it looks like that the next element gets the state of this modifier. When i use the key() {} code it works fine.
Copy code
LazyColumn {
    items(modelList) { item ->
        //key(item) { // with key it works fine
            Box(Modifier.swipeToRemove(onRemoved = {
            })) {
                Item(item = item)


01/28/2021, 1:21 PM
We don't have automatic keys in LazyColumn just yet, it's recommended to use key for such things for now, so you are doing everything right here 🙂

Timo Drick

01/28/2021, 1:22 PM
ok thx @matvei

Andrey Kulikov

01/28/2021, 3:50 PM
to elaborate: the position in the list is the key. so when the item with index 2 is removed the item which was previously third is now second and has its state. quite soon we will have an official solution for keys in LazyColumn which would support reordering/removings. just using key{} as you did is not solving all the issues
but works for this case 🙂