https://kotlinlang.org logo
#compose
Title
# compose
n

Nat Strangerweather

06/04/2022, 1:20 PM
I'm trying to understand how to read the Recomposition Counts in Layout Inspector. It looks like there might be a problem with my text. Could someone please have a look at my screenshot in thread?
The text seems to be getting recomposed but the recompositions come up as "skipped". The text does not need to be recomposed more than once, but I'm not sure what to use. When I use
derivedStateOf
I can't seem to access my value further down the line...
Copy code
val superscript =
            SpanStyle(
                baselineShift = BaselineShift.Superscript,
                fontSize = 12.sp,
                color = Color.White
            )

[...]

Text(
            text = buildAnnotatedString {
                append(data.name)
                withStyle(superscript) {
                    append("  ${data.value}")
                }
            }, style = TextStyle(Color.White, fontSize = 20.sp),
            fontWeight = FontWeight.ExtraBold
        )
s

Saiedmomen

06/04/2022, 5:05 PM
In which version of android studio is this available?
n

Nat Strangerweather

06/04/2022, 5:06 PM
Electric Eel
🙏 1
a

Albert Chang

06/04/2022, 5:29 PM
When
MainPiece
is recomposed, all its children are recomposed (and some of the recompositions may be skipped) so what you should look is
MainPiece
.
n

Nat Strangerweather

06/04/2022, 5:37 PM
Hmm, I'm wondering about these 65 recompositions, is that a lot?
s

Stylianos Gakis

06/04/2022, 6:23 PM
Depends, if you’re running an animation it seems quite normal I would guess. If you’re supposedly showing stable data to the screen then it doesn’t look normal.
n

Nat Strangerweather

06/04/2022, 6:26 PM
Ah ok, yes, I have an animation (animateColorAsState) so that makes sense then. It's also after about 5 to 10 clicks. Thanks!
🤗 1
4 Views