<https://developer.android.com/jetpack/compose/lis...
# compose
a
https://developer.android.com/jetpack/compose/lists#item-keys Is it preferable to always provide stable keys when available, or are there downsides to using it?
h
I'd say there is really no downside to using key when available. To understand it better I'd recommend checking this thread out. Key concept is very similar in React and Jetpack Compose.
a
I see. Thank you, I’ll check it out
c
Yes, it’s preferable to always provide a key
h
If it is preferable, why does compose do not require them, like SwiftUI with Identifiable?
a
I just discovered it, actually, I’ve never used it in my LazyColumn. I just saw it recently in the changelog and it’s about adding the support for the Paging Items.
c
Such a great thread @Halil Ozercan 💯
c
Keys were a late addition to the LazyList DSL so I don’t believe there was a way to make them mandatory at the time. @Andrey Kulikov
a
there are some limitations with keys - the value you provide should be saveable into a Bundle, plus keys should be unique between all the elements in the list. when you don’t provide a key then indexes are used as keys internally
👍 1
c
Indexes as a fallback makes sense. A lint rule for this would be great I think though.