Questions tagged [compose-recomposition]
167 questions
56
votes
4 answers
What does Jetpack Compose remember actually do, how does it work under the hood?
Checking out codelab's basic tutorial there is a snippet to increase counter on button when clicked
@Composable
fun MyScreenContent(names: List = listOf("Android", "there")) {
val counterState = remember { mutableStateOf(0) }
…

Thracian
- 43,021
- 16
- 133
- 222
37
votes
2 answers
What do the @Stable and @Immutable annotations mean in Jetpack Compose?
While studying through the Jetpack Compose sample project, I saw @Stable and @Immutable annotations. I've been looking through the Android documentation and GitHub about those annotations, but I don't understand.
From what I understand, if use…

Ji Sungbin
- 891
- 1
- 10
- 19
22
votes
1 answer
Jetpack Compose NavHost recomposition composable multiple times
I found out that the composable screens are getting recomposition multiple times during navigation from Navhost compose
the following example shows how I'm integrating the navigation with logs to identify how many time the function is getting…

tamtom
- 2,474
- 1
- 20
- 33
21
votes
3 answers
Jetpack Compose: The layout inspector is not showing the menu for recomposition counts
Android Studio Bumblebee Patch 3
From this page, it says that I can see recomposition counts:
https://developer.android.com/jetpack/compose/tooling#recomposition-counts
It does not show the menu option to me. Only the device name and "Stop…

user2343647
- 633
- 6
- 17
21
votes
3 answers
Difference between remember and rememberUpdatedState in Jetpack Compose?
I'm confused, can someone explain me the difference between:
val variable by remember { mutableStateOf() }
and
val variable by rememberUpdatedState()
When I check the source code of rememberUpdatedStates I actually see: remember { mutableStateOf()…

Stefan
- 2,829
- 5
- 20
- 44
14
votes
1 answer
Jetpack Compose Smart Recomposition
I'm doing experiments to comprehend recomposition and smart recomposition and made a sample
Sorry for the colors, they are generated with Random.nextIn() to observe recomposition visually, setting colors has no effect on recomposition, tried…

Thracian
- 43,021
- 16
- 133
- 222
11
votes
3 answers
Jetpack Compose @Stable List parameter recomposition
@Composable functions are recomposed
if one the parameters is changed or
if one of the parameters is not @Stable/@Immutable
When passing items: List as parameter, compose always recomposes, regardless of List is immutable and cannot be…

Jemshit
- 9,501
- 5
- 69
- 106
10
votes
2 answers
Jetpack Compose lazy column all items recomposes when a single item update
I'm trying to do some list operations and I've run into the issue of all items recomposing when a single item update.
https://prnt.sc/8_OAi1Krn-qg
My models;
data class Person(val id: Int, val name: String, val isSelected: Boolean =…

pcparticle
- 123
- 1
- 6
9
votes
1 answer
What are benefits of @Immutable on a data class?
Looking at the documentation of Immutable, there's a code example:
@Immutable
data class Person(val name: String, val phoneNumber: String)
@Composable
fun PersonView(person: Person) {
Column {
Row {
Text("Name: ")
…

dominik
- 2,404
- 2
- 29
- 33
8
votes
2 answers
Jetpack Compose Arc/Circular Progress Bar Animation (How to restart animation)
How do I create a Arc Progress bar animation like this
Currently I've already used Canvas to draw an arc and added animations to the progress bar using animateFloatAsState API. But second pic is not my expected.
[]
// e.g. oldScore = 100f …

Claire
- 93
- 6
8
votes
1 answer
Jetpack Compose Lazy Column single selection
I'm getting data from the server and displaying it in the list, each item can be selected with one click to display the button, but I cannot close it, I can only open it.
This is item of list class
data class Task(
val deviceName: String,
…

卡尔斯路西法
- 83
- 5
8
votes
1 answer
Jetpack Compose TextField not updating when typing a new character
I followed this document from the developer site.
I want to display the text in an OutlinedTextField from a user input, and have it survive configuration changes.
With the code below, when the user inputs the text from the keyboard,…

Zappy.Mans
- 551
- 1
- 7
- 19
7
votes
3 answers
Animate visibility in compose
I have a text which need to be animated to show and hide with the value is null or not. it would have been straight forward if the visibility is separately handle, but this is what I got.
In the bellow code the enter animation works but the exit…

SproutinGeek
- 327
- 3
- 19
7
votes
1 answer
Screen not recomposing when state value changes - Jetpack Compose
It is a video call screen . It needs token and channel name to work which needs to be passed to init call engine. I am storing these in a data class which is used as a mutable state.
Screen State Data class
@Keep
data class CallScreenState(
val…

Harish Padmanabh
- 307
- 4
- 17
7
votes
2 answers
Compose - NavHost recomposition multiple times
During navigation from Navhost, I found out that the composable screens are getting recomposition multiple times. Because of it, my ViewModel is calling API data source multiple times too.
@Composable
fun MainView() {
val scaffoldState =…

LMaker
- 1,444
- 3
- 25
- 38