0Pricing
Jetpack Compose Academy · Lesson

Recomposition: What Triggers a Redraw

Understand when Compose re-runs your code.

Recomposition: What Triggers a Redraw is a free Jetpack Compose Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Jetpack Compose Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Is Recomposition?

Recomposition is Compose re-running your Composable functions to update the screen after some state they read has changed.

Triggered by State Reads

A redraw is triggered only when a piece of state a Composable read actually changes. No state change means no recomposition.

Only Readers Re-Run

Compose is smart: it re-runs only the Composables that read the changed state, not your whole screen. This keeps updates cheap.

Recomposition Can Skip

If a Composable's inputs did not change, Compose may skip re-running it entirely. Unchanged work is simply reused.

It Can Run Out of Order

Compose may recompose Composables in any order or even in parallel. Never assume one runs before another.

It Can Run Often

Recomposition can happen frequently, even every animation frame. Your Composable code should be fast and lightweight.

Keep Composables Pure

Treat Composables as side-effect free. Avoid writing files or starting work directly in the body, since it may re-run many times.

@Composable
fun Greeting(name: String) {
    Text("Hi " + name)
}

Watch a Counter Recompose

Each time count changes, the Text that reads it recomposes and shows the new number, while untouched siblings stay put.

var count by remember { mutableStateOf(0) }
Text("Value: " + count)

Don't Do Heavy Work Inline

Running an expensive calculation in the body repeats it on every recomposition. Move it out or remember the result.

remember Caches Computations

Wrap a costly value in remember so Compose computes it once and reuses it across recompositions instead of redoing the work.

val sorted = remember(items) { items.sorted() }

Mental Model

Think of the UI as a function of state. Change the state, Compose recomputes the affected parts, and the screen follows.

Quick Check

What actually triggers a recomposition?

Recap

You now know recomposition re-runs only the readers of changed state, can run often and out of order, so keep Composables fast and pure. 🎯

Frequently asked questions

Is the “Recomposition: What Triggers a Redraw” lesson free?

Yes — the full text of “Recomposition: What Triggers a Redraw” is free to read here on the web, and the Jetpack Compose Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Jetpack Compose Academy course, upgrade to CoddyKit PRO.

What will I learn in “Recomposition: What Triggers a Redraw”?

Understand when Compose re-runs your code. You practise Jetpack Compose Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Jetpack Compose Academy?

No prior experience is required. Jetpack Compose Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Recomposition: What Triggers a Redraw” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Jetpack Compose Academy lesson?

Yes. Every Jetpack Compose Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. remember & mutableStateOf
  2. Recomposition: What Triggers a Redraw
  3. Build a Tap Counter
  4. rememberSaveable Across Rotation
← Back to Jetpack Compose Academy