0Pricing
Jetpack Compose Academy · Lesson

Deferring State Reads

Read state late to shrink recomposition scope.

Deferring State Reads is a free Jetpack Compose Academy lesson on CoddyKit — lesson 3 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.

Reading State Has a Cost

Every place you read a Compose state value becomes a subscriber. When that state changes, every reader recomposes.

Recomposition Scope

The nearest enclosing Composable that reads a state is its recomposition scope. Read high up, and a lot redraws together.

Read Low, Redraw Less

If you read state deeper, only that small Composable recomposes. Pushing the read down shrinks how much work happens.

The Lambda Trick

Pass a lambda that returns the value instead of the value itself. The read then happens later, inside a narrower scope.

Box(Modifier.offset { IntOffset(0, scroll.value) })

Modifier.offset Example

The lambda offset reads scroll position during layout, not composition, so animating it skips recomposition entirely.

Defer with derivedStateOf

derivedStateOf recomputes only when its result truly changes, so a frequently changing source updates readers far less often.

val showButton by remember { derivedStateOf { scroll.value > 100 } }

Cut the Noise

Without derivedStateOf, a button reading raw scroll redraws on every pixel. With it, the button recomposes only when the boolean flips.

Avoid Reading in the Parent

Reading state in a parent just to pass it down forces the parent and all siblings to recompose. Pass the state object instead.

Pass State, Not Value

Hand a child the whole State object and let it read inside itself. The parent stays stable while the child updates alone.

Lazy Lists Love Deferring

In a LazyColumn, deferred reads keep scroll updates from re-running item content, so long lists stay buttery smooth.

Read Late, Run Less

The core habit is simple: delay the moment you read state until the smallest possible scope needs it.

Quick Check

Confirm the deferring idea.

Recap: Defer the Read

Read state in the smallest scope, use lambda modifiers and derivedStateOf, and pass State objects down to keep redraws tiny. ✅

Frequently asked questions

Is the “Deferring State Reads” lesson free?

Yes — the full text of “Deferring State Reads” 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 “Deferring State Reads”?

Read state late to shrink recomposition scope. 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 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Deferring State Reads” 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. Stable vs Unstable Parameters
  2. Skipping, @Stable & @Immutable
  3. Deferring State Reads
  4. Layout Inspector & Recomposition Counts
← Back to Jetpack Compose Academy