# Jetpack Compose in Depth

> Recomposition, state hoisting, remember and side effects, modifiers, theming and lazy layouts in Compose. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/mobile/compose-in-depth
Last updated: 2026-11-28

Recomposition, state hoisting, remember and side effects, modifiers, theming and lazy layouts in Compose.

Intermediate · about 10 hours · difficulty 3/5

Learn first: [Android Components, Lifecycle & Gradle](https://www.internhack.in/roadmaps/tracks/mobile/android-fundamentals)

Compose redraws UI by **recomposing** composable functions when the state they read changes. Writing fast, correct Compose means working with that model, not against it.

### State and recomposition

- `remember { mutableStateOf(...) }` keeps state across recompositions; `rememberSaveable` also survives configuration changes.
- **State hoisting**: make composables stateless by passing `value` and `onValueChange`, keeping state in the caller or a ViewModel. This makes them reusable and previewable.
- Composables should be **side-effect free**: they can run many times, in any order.

### Side effects

- `LaunchedEffect(key)` runs a coroutine when the key changes.
- `DisposableEffect` sets up and tears down listeners.
- `rememberCoroutineScope` launches work from click handlers.

### Modifiers and layout

Modifier order matters: `padding` then `background` differs from the reverse. Use `LazyColumn`/`LazyVerticalGrid` with `key` for lists.

### Tooling

`@Preview` for fast iteration, Layout Inspector to count recompositions.

### Pitfalls

Reading rapidly changing state (scroll position) high in the tree recomposes everything; read it as late as possible or use `derivedStateOf`.

**Good enough to move on:** you built a stateless, previewable form component whose state lives in a ViewModel.

## Key concepts

- **Recomposition**
- **remember and rememberSaveable**
- **State hoisting**
- **Side-effect APIs**
- **Modifier ordering**
- **Lazy lists and grids**
- **Previews and Layout Inspector**
- **derivedStateOf and stability**

## Mini project

Build a habit tracker in Compose with a lazy list, a stateless habit row component, previews for each state, and a LaunchedEffect-driven reminder banner.

## Check yourself

Why should a composable never perform a network request directly in its body?

## Free resources

- [Jetpack Compose](https://developer.android.com/jetpack/compose) (Android Developers)
- [State and Jetpack Compose](https://developer.android.com/develop/ui/compose/state) (Android Developers)
- [Side-effects in Compose](https://developer.android.com/develop/ui/compose/side-effects) (Android Developers)

Previous: [Android Components, Lifecycle & Gradle](https://www.internhack.in/roadmaps/tracks/mobile/android-fundamentals) · Next: [Modern Android Architecture: ViewModel, Flow, Hilt & Room](https://www.internhack.in/roadmaps/tracks/mobile/android-architecture)

## More in Android with Kotlin in Depth

- [Android Components, Lifecycle & Gradle](https://www.internhack.in/roadmaps/tracks/mobile/android-fundamentals)
- [Jetpack Compose in Depth](https://www.internhack.in/roadmaps/tracks/mobile/compose-in-depth)
- [Modern Android Architecture: ViewModel, Flow, Hilt & Room](https://www.internhack.in/roadmaps/tracks/mobile/android-architecture)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Mobile App Developer Roadmap](https://www.internhack.in/roadmaps/tracks/mobile)
