article banner (priority)

Quiz: Do you understand recomposition and stability?

So you think you understand recomposition and stability? Let's find out with those few simple questions:

Quiz

Question 1 of 10

Which functions (a, b, c, or d) will be called when the button “Click me” is clicked?
fun Text() { var text by remember { mutableStateOf("Hello, World") } a() Card { b() Column { c() if (text.isNotEmpty()) { d() Text(text) } } } Button({ text += "!" }) { Text("Click me") } }

Question 2 of 10

What should be used to store user text input in a form?

Question 3 of 10

What should be used to store an OkHttp WebSocket connection? (you don't want it lost in case od configuration changes)

Question 4 of 10

What should be used to store state observed from StateFlow?

Question 5 of 10

What should be used to store scroll state?

Question 6 of 10

What is the right way to define imageUrl?

Question 7 of 10

What is the right way to define initials?

Question 8 of 10

Which of those types are unstable in Compose?

Question 9 of 10

Which of those classes are unstable in Compose?

Question 10 of 10

data class UserUiState( val user: UserUi, val userSettings: UserSettingsUi, ) data class UserUi( val name: String, val surname: String, ) data class UserSettingsUi( val allowNewsletter: Boolean, ) @Composable fun UserScreen(viewModel: UserScreenViewModel = injectViewModel()) { val uiState: UserUi by viewModel.uiState.collectAsStateWithLifecycle() UserCard(uiState.user) UserSettings(uiState.userSettings, { viewModel.toggleAllowNewsletter(it) }) } @Composable fun UserCard(user: UserUi) { Text(user.name) Text(user.surname) } @Composable fun UserSettings(userSettings: UserSettingsUi, toggleAllowNewsletter: (Boolean) -> Unit) { Switch( checked = userSettings.allowNewsletter, onCheckedChange = toggleAllowNewsletter ) }
What will recompose if on the view model:
_uiState.update { it.copy(user = it.user.copy(name = "New name")) }
How is your score?
  • 0-3 If you plan to implement Compose applications, you should better learn about stability and recomposition
  • 4-6 This is nice, but there is room for improvement
  • 7-9 You are doing great, keep it up!
  • 10 Nice! You seem to understand recomposition and stability pretty well
All those topics are covered in the first two days of Advanced Compose.
If you’d like a clear, structured reference for the parts that cause the most confusion, grab the cheat sheet below.
A practical 10-page reference covering:
  • Modifiers (layout, interaction, drawing, transformations)
  • MaterialTheme & CompositionLocal setup
  • Stability rules (what’s stable vs unstable — and why it matters)
  • What actually triggers recomposition
  • Delayed state reads & hoistable stable state patterns
📖 100% free
📬 Join 20k+ Kotlin developers receiving practical weekly insights
❌ No spam. Unsubscribe anytime.
Get your free cheat sheet → Here