Questions tagged [compose-recomposition]
167 questions
6
votes
2 answers
Jetpack Compose: how to reset LazyListState?
I have a LazyColumn with nested LazyRows (similar to Netflix or Spotify home page feed). In short, the issue I'm having is that when the content of the page changes, the scrolling positions of the nested LazyRows are not reset.
For example, user…

Ziad Halabi
- 964
- 11
- 31
6
votes
1 answer
How to trigger recomposition when only a property of an object changes Jetpack-Android
Imagine the following object
data class CourseState(
val key:Int=0,
val name:String="",
val courses:Courses=Courses())
Implementing the following pattern
private val _courseState = mutableStateOf(CourseState())
val courseState: State =…

quealegriamasalegre
- 2,887
- 1
- 13
- 35
6
votes
1 answer
How to favor Smart Recomposition in Jetpack Compose
The Jetpack compose documentation says it can skip recomposition if all the inputs are stable and haven't changed. The definition of a type being stable goes like this...
A stable type must comply with the following contract:
The result of equals…

Sundaravel
- 464
- 5
- 16
5
votes
1 answer
Composable doesn't re-compose on button click
I have the following composable function. Its a simple login screen with username, password and submit button.
If username or password fields are empty when the user clicks on the submit button a snackbar will show. However, it works on the first…

ant2009
- 27,094
- 154
- 411
- 609
5
votes
1 answer
Observing Soft Keyboard Visibility, Opened/Closed Jetpack Compose
I'm trying to actively observe the soft keyboard visibility, currently, I'm trying to observe it with
WindowInsets.isImeVisible
but I can't seem to observe its state change. Someone mentioned using
ViewCompat.setOnApplyWindowInsetsListener()
but I…

JayDee
- 83
- 4
5
votes
1 answer
TabRow/Tab Recomposition Issue in Compose Accompanist Pager
I was trying to create a sample Tab View in Jetpack compose, so the structure will be like
Inside a Parent TabRow we are iterating the tab title and create Tab composable.
More precise code will be like…

J.K
- 2,290
- 1
- 18
- 29
5
votes
1 answer
Fetching words from Firestore does not update LazyColumn Jetpack Compose
@Composable
fun getData() {
var wordData = arrayListOf()
db.get().addOnSuccessListener { documents ->
for (document in documents) {
wordData.add(document.toObject(Word::class.java))
}
…
user20197752
5
votes
1 answer
Removing item from the list causes wrong display in LazyColumn
So here's an odd one, I think. I'm showing a list of Textfields in a LazyColoumn. The user can remove each of the textfields, but when doing so, it copies the value from REPLACE textfield.
What's happening:
I have added 3 people: Person 1, Person…

MikkelT
- 633
- 1
- 10
- 16
5
votes
1 answer
Jetpack compose lazy column not recomposing with list
I have a list which is stored inside a Viewmodel via Stateflow.
class FirstSettingViewModel : ViewModel() {
private val _mRoomList = MutableStateFlow
- >(mutableListOf())
val mRoomList: StateFlow
- > = _mRoomList
…

March3April4
- 2,131
- 1
- 18
- 37
5
votes
2 answers
Jetpack Compose recomposition race condition
Suppose we have the following code. It displays a button, and when the user clicks on it, the button disappears.
@Composable
fun ButtonThatDisappearsOnClick() {
var showButton by remember { mutableStateOf(true) }
if (showButton) {
…

Lev Leontev
- 2,538
- 2
- 19
- 31
5
votes
2 answers
Jetpack compose mutableStateOf list doesn't trigger re-composition when changing property value in list item class
I think I'm missing a core concept of Jetpack Compose here. I'm running into an issue when I'm trying to change a non-constructor data class property inside of a composable when this composable is part of an observed list.
Does not work:…

TickL Me Tibbers
- 53
- 1
- 6
5
votes
1 answer
Jetpack Compose , mutable state causes infinite recomposition when navigating with NavHost
Here is the code that causes the infinite recomposition problem
MainActivity
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
…

TheRealAzubal
- 75
- 6
5
votes
2 answers
Continuous recomposition in Jetpack Compose
I'm trying to create a sky view in my Android app using Jetpack Compose. I want to display it inside a Card with a fixed height. During nigth time, the card background turns dark blue and I'd like to have some blinking stars spread over the sky.
To…

Pion Developer
- 97
- 9
5
votes
0 answers
How does backwards write in Jetpack Compose work?
We have the official docs showcasing an example of backwards write in Compose:
@Composable
fun BadComposable() {
var count by remember { mutableStateOf(0) }
// Causes recomposition on click
Button(onClick = { count++ },…

Catalin Ghita
- 794
- 8
- 26
5
votes
1 answer
Jetpack Compose, recomposition won't trigger when using custom Lifecycle/ViewModelStore/SavedStateRegistry Owner
I'm trying to create an overlay and attach the view to the WindowManager, I've managed to do this by creating a class which implements Lifecycle/ViewModelStore/SavedStateRegistry Owner.
But for some reason whenever I try to show a dialog/change the…

Gabriel Ilie
- 53
- 6