You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Proposing it should just always issue a warning if .hashcode is called from the key lambda for all types.
As Compose docs say that item keys must be unique and LazyColumn/Row throw an exception if it detects a non-unique hashcode and hashcodes are generally never guaranteed to be unique (by design) so it is never a good choice for an key.
Might work just fine until some day data from the server comes along with a dup hashcode and starts causing crashes.
Should instead find some other unique thing to use, an ID from the server, or java.lang.System.identityHashCode (if you aren't doing KMP) or a atomically incremented count fed into the state classes at construction time.
Proposed rule: don't use hashCode in the item key for Lazy* Composables
Item key should be unique.
.hashCode()
is not unique.e.g. these all have the same hash code, even on JS, WASM, etc, same hashcode is unlikely, but not impossible in the wild.
The text was updated successfully, but these errors were encountered: