Questions tagged [compose-recomposition]
167 questions
4
votes
1 answer
Jetpack Compose: LazyColumn not updating with MutableList
I am trying to strikethrough a text at the click of a button using Jetpack Compose but the UI is not updating.
I have tried to set a button and on the click of a button, deletedTasks gets updated and if my task is in deletedTasks then it should show…

Roh
- 311
- 1
- 10
4
votes
1 answer
Jetpack Compose animateFLoatAsState replaced by Transition.animateFloat is not working
Could you tell me why it stops working when I use val animateAngle: Float by transition.animateFloat instead of val animateAngle by animateFloatAsState?
It seems that the variable rotated is not updated when the button is clicked.
var rotated…

ntos
- 189
- 10
4
votes
1 answer
How to use remember & mutableStateOf seperately?
Usually, compose codes are like
@Preview
@Composable
fun BuildMyView() {
val counter = rememberSaveable { mutableStateOf(1) }
Text(
modifier = Modifier
.fillMaxSize()
.wrapContentSize(align =…

michael
- 75
- 7
4
votes
1 answer
Are there any tools or way to test recomposition happens in a piece of code or not in Jetpack compose?
Are there any tools or way to test recomposition happens in a piece of code or not in Jetpack compose?

Sepideh Vatankhah
- 597
- 5
- 17
4
votes
1 answer
When recomposition happens exactly? with changing the state or also with changing the input
As far as I understood, each part of code which is related to any state will be changed(recomposed) with state changes →
And each state is an observable and the dependent UI part observes that state and is subscribed to it(the state) and whenever…

Sepideh Vatankhah
- 597
- 5
- 17
3
votes
1 answer
Are interfaces always unstable in Jetpack Compose?
In the official documentation, a List is always recomposed, even if its collection is actually the same, because "this is an Interface, and its implementation can be mutable", and this is indeed how it behaves (if you use Layout Inspector to extract…

H.Kim
- 525
- 4
- 14
3
votes
1 answer
Stability and @Stable annotation in Jetpack Compose?
Stability and Skippability
In jetpack Compose stability, not triggering recomposition when inputs of a function hasn't changed, is achieved by using immutable variables or/and using @Immutable or @Stable annotation to make functions skippable as can…

Thracian
- 43,021
- 16
- 133
- 222
3
votes
2 answers
How does Jetpack Compose detect change in variable for recomposition
I am doing a Google Codelab and have the following code (drawable changes when button is pressed):
@Composable
fun DiceWithButtonAndImage(modifier: Modifier = Modifier) {
var result by remember { mutableStateOf(1) }
val imageResource = when…

Vamoos
- 327
- 4
- 10
3
votes
1 answer
Android compose ModalBottomSheetLayout causes enormous recomposition counts
I'm working with compose now for several weeks and some things are still quite challenging or weird I think.
My newest feature requires a BottomSheet, a ModalBottomSheet to be precise.
When inspecting via the Layout Inspector it shows me, that the…

PadySo
- 55
- 5
3
votes
3 answers
Lambda function used as input argument causes recomposition
Consider snippet below
fun doSomething(){
}
@Composable
fun A() {
Column() {
val counter = remember { mutableStateOf(0) }
B {
doSomething()
}
Button(onClick = { counter.value += 1 }) {
…

Ali Golmirzaei
- 61
- 7
3
votes
1 answer
Text is not updating even though I am using remember and mutableStateOf
I've run into a strange issue in Jetpack Compose. I am currently working on an app which shows data on a graph from an external API. I am fetching data with no problem, but my graph didn't recompose with new values.
After debugging, I started to…

jakgrab
- 33
- 5
3
votes
1 answer
Jetpack compose: Pending composition has not been applied when rememberSaveable is used
I had a search view that worked fine but didn't keep the user input on back navigation (from detail view).
According to Keep text in BasicTextField on back navigation, all i had to do was to change
remember
to
rememberSaveable
like so:
val…

Dmitri
- 2,563
- 1
- 22
- 30
3
votes
1 answer
Why does the image not render in Android Studio when an integer variable containing the drawable is passed to the painterResource function?
I have a requirement to display different images based on certain user interactions. So, I'm storing the drawable resource ID in an integer variable. However, when I pass this variable into the Image's painterResource function the image is not…

Varad G
- 87
- 7
3
votes
2 answers
What/Where is the best way to handle with states on Jetpack Compose?
I've seen some Jetpack Compose projects and I've seen two types of managing states, not realizing which one is better.
For example, let's assume: the input state. I've seen people manage this state in the UI, using remember to save the state of the…

R0ck
- 409
- 1
- 15
3
votes
1 answer
Navigation is being called every time in Jetpack Compose
I'm implementing registration in my application and, after filling in the respective fields, I click on a button that will make a registration request to the API. Meanwhile, I place a Loading View and when I receive the successful response, I…

R0ck
- 409
- 1
- 15