https://kotlinlang.org logo
j

jim

09/17/2020, 9:14 AM
MyList(items)
takes in a
MutableList
, which is (as the name suggests) mutable, so Compose can't know if that list has been modified or not, so it needs to be conservative and rerun that code. If you use a list implementation that is stable (like
SnapshotStateLIst
then
MyList(items)
is less likely to run. Having said that, keep in mind that your code should NEVER make assumptions about when composables will run. Compose is free to run composable functions for any reason and at any time, at its sole discretion.
👍 1