deferring-state-reads

Migrate Compose value-form modifiers to lambda forms to defer state reads.

472|16|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/skydoves/compose-performance-skills --skill deferring-state-reads
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: deferring-state-reads
Source: https://github.com/skydoves/compose-performance-skills/tree/main/recomposition/deferring-state-reads
Command: npx skills add https://github.com/skydoves/compose-performance-skills --skill deferring-state-reads

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Deferring hot Compose state reads from the Composition phase to Layout or Draw reduces per-frame recomposition by moving state reads into lambda modifiers, enabling smoother UI with frequent changes like scroll or animation.

Core Features & Use Cases

  • Move state reads like scroll offsets, animation progress, and drag deltas into lambda modifiers such as Modifier.offset { }, Modifier.layout { }, Modifier.graphicsLayer { }, and Modifier.drawBehind { }.
  • Hoist hot values across composables using lambda providers (() -> T) so only the Layout/Draw phase reads trigger invalidation.
  • Verify performance improvements with Layout Inspector or @TraceRecomposition while preserving visuals and behavior.

Quick Start

Identify a hot state read in a composable body and replace a value-form modifier with a lambda modifier to move the read into the Layout or Draw phase.

Frequently Asked Questions about deferring-state-reads

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce Jetpack Compose recomposition during scroll and animation?

To reduce Compose recomposition during scroll and animation, defer hot state reads from the Composition phase to Layout or Draw by migrating value-form modifiers to lambda forms like Modifier.graphicsLayer { }. This moves invalidation downstream, skipping per-frame recomposition.

What is deferring state reads in Jetpack Compose?

Deferring state reads in Compose is the technique of moving hot state reads, such as scroll offsets and animation progress, out of the composable body and into lambda modifiers. This shifts invalidation from the Composition phase to the Layout or Draw phase for smoother UI.

How do I move scroll offset state reads to the Layout or Draw phase in Compose?

You can move scroll offset state reads to the Layout or Draw phase by replacing value-form modifiers with lambda modifiers like Modifier.offset { } or Modifier.drawBehind { }. Hoist hot values across composables using lambda providers (() -> T) to ensure only Layout or Draw phases invalidate.

Does deferring state reads work with older Compose UI versions?

Deferring state reads using lambda modifiers requires Compose UI 1.7 or higher. You must verify performance improvements using Layout Inspector or @TraceRecomposition to ensure only the lambda-formed reads invalidate the Layout or Draw phases without triggering recomposition.

Why does my Compose animation still trigger recomposition when using lambda modifiers?

If your Compose animation triggers recomposition with lambda modifiers, verify the state read is fully hoisted into the lambda block and not evaluated in the composable body. Use @TraceRecomposition to check if value-form reads are accidentally bypassing the deferral and invalidating Composition.

What is the best way to verify Compose performance improvements from deferring state reads?

The best way to verify Compose performance improvements from deferring state reads is using Layout Inspector or @TraceRecomposition. These tools confirm that lambda-formed modifier reads only invalidate the Layout or Draw phases, preserving visuals and behavior while reducing recomposition frequency.