```could someone help me understand why this happe...
# compose
g
Copy code
could someone help me understand why this happens in recomposition count? It happens to me in all apps, I think it's an android bug
r
I think it's working as expected
What should not be recomposing?
g
Button recompose 40 counts when i clicked 5 times
r
You can disable recomposition by setting
elevation = null
That happens because it implements
DefaultButtonElevation
and this listens for any
interactionSource
changes, so when you press it/release/hover, it's doing some kinda of animation and applying it to the box elevation inside button I don't think is something you should worry, nevertheless good question though 🙂
If you're interested on how it works, dig inside the Button and you'll find what's going on or at least the root cause
g
perdona eres español?
por tu nombre digo
entiendo mas o menos lo que dices pero no del todo
1. no entiendo donde hay que poner eleveation = null, es un valor que viene por defecto de button?
vale creo que ahora mirandolo lo entiendo
voy a probar
ya ves tio
tenias razon
que paranoya
r
Si, soy español! Pero estaría bien hablar en inglés si no te importa así los demás puedan entender lo que decimos y contribuir si hace falta jaja
g
ahora la pregunta es: ¿Es correcto tener eso así y que se recomponga cuanto le plazca?
OK, sorry I understand english very slow
r
No worries 😉
¿Es correcto tener eso así y que se recomponga cuanto le plazca?
I'm not sure about that, maybe it's not possible to skip
Composition
phase, I haven't dig it up too much there. But recomposition is not bad, just I would forget about it unless you think it's costing you performance in your app, which I don't think it's the case
g
Copy code
c'mon, actually, I've done exactly what you told me (elevation = null).
The problem is this: if I'm optimizing my jetpack compose app and I need to know how many times elements are recomposed, leaving this free might seem a bit confusing.
r
If that is your concern then no worries this shouldn't affect your app, since recomposition happens inside Button and the nearest scope is the
Button
scope, so it won't recompose any other parts of the app
But, keep in mind that recomposition is not bad unless you notice some performance issue In this case, let Button recompose as much as it needs when interacting with it, it's an animation, it's supposed to be recomposed 😄
g
ok, thanks you very much!
a
The ripple animation is the reason of most of the recompositions, is not something bad (it's actually the expected behavior), as not everything is recomposed, just the parts that need to change like the background. Elevation changes and other interactions affect as @robercoding has already explained. Spanish: La mayoría de las recomposiciones son por la animación del ripple, lo cual no es algo es algo malo (es el comportamiento esperado), ya que no se recompone todo, tan solo las partes que lo necesitan como podría ser el fondo en el caso de esta animación. Los cambios de elevación y otras interaciones también afectan tal y como Roberto ha mencionado.