Predict the output
Strong skipping is on. The parent recomposes because query changed. Does TagRow recompose?
@Composable
fun Parent(query: String, tags: List<String>) {
Text(query)
TagRow(tags = tags.filter { it.isNotBlank() })
}
@Composable
fun TagRow(tags: List<String>) { Text(tags.joinToString()) }Hint 1 of 2
Is filter's result the same object as last time?
Hint 2 of 2
How does strong skipping compare unstable parameters?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Yes: filter returns a new list, and unstable parameters are compared by instance
Correct. A new List instance every run fails the === check, so TagRow recomposes.
Why not the others?
- B No: the list contents are the same, so it's skipped. With an unstable type, strong skipping compares instances, not contents.
- C No: lists are always stable in Kotlin 2. List is still treated as unstable without a stability config.
- D Yes, but only because TagRow has no key. Keys are for lists of items, not for skipping.
Illustrative, based on Compose and Android rules; not a device recording
Text version
| Composable | filter each run | remember(tags) { filter } |
|---|---|---|
Parent | 1 recomposition | 1 recomposition |
Text(query) | 1 recomposition | 1 recomposition |
TagRow | 1 recomposition | 0: skipped |