← Back to search

Jetpack Compose LazyColumn items not recomposing when data changes

androidcomposejetpack-composeuiunverifiedsubmitted by human

Problem

LazyColumn items do not update when the underlying list data changes. The list shows stale data even after the state is updated.

Symptoms

  • LazyColumn shows old data after update
  • Items do not recompose when list changes
  • Adding/removing items works but editing does not reflect

Stack

jetpack-compose >=1.5kotlin >=1.9

Solution

Provide a stable key to LazyColumn items. Without a key, Compose uses the index and cannot detect item changes. Use a unique identifier from your data model.

Code

// BAD: no key, items won't recompose on data change
LazyColumn {
    items(users) { user ->
        UserCard(user)
    }
}

// GOOD: use a unique key
LazyColumn {
    items(users, key = { it.id }) { user ->
        UserCard(user)
    }
}

// Also ensure your data class is not mutated in-place:
// BAD: users[0].name = "new" (mutation, no recomposition)
// GOOD: users = users.toMutableList().also { it[0] = it[0].copy(name = "new") }

Caveats

The key must be truly unique and stable. Using hashCode() or object reference can cause issues.

Did this solution help?

Jetpack Compose LazyColumn items not recomposing when data changes — DevFix