You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When Tip3 is recomposed, even if the CardInfo value doesn't change, a new lambda will be created and passed to GoodGreetingsTip3, which will cause a complete recomposition down to GoodInnerColumn.
actually after doing some further reading, it looks like in this case, using a lambda was ok, because the only captured value is a stable type, the compiler should actually mark the lambda as stable, and will be able to skip.
Hi,
In the tip3, I think there's a potential catch that can trigger unncessary recompositions.
The declaration of the lambda at this line:
https://github.com/AidaIssayeva/recomposition_examples/blob/main/app/src/main/java/com/cupsofcode/recomposition_examples/Tip3.kt#L49
When
Tip3
is recomposed, even if theCardInfo
value doesn't change, a new lambda will be created and passed toGoodGreetingsTip3
, which will cause a complete recomposition down toGoodInnerColumn
.This article is explaining why it happens and some solutions: https://proandroiddev.com/understanding-re-composition-in-jetpack-compose-with-a-case-study-9e7d96d98095
This isn't exactly the topic of the tip, but since this is a very common case, I think it would be worth to fix it.
The easy fix:
GoodGreetingsTip3(cardInfo::value)
Edit: might also be worth to add a comment to explain this
The text was updated successfully, but these errors were encountered: