compose-state-hoisting

Guide Android developers to hoist Compose UI state to the correct scope.

1|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/leogallego/ansible-jane --skill compose-state-hoisting-leogallego
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compose-state-hoisting
Source: https://github.com/leogallego/ansible-jane/tree/main/skills/compose-state-hoisting
Command: npx skills add https://github.com/leogallego/ansible-jane --skill compose-state-hoisting-leogallego

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps Android developers decide where to place Jetpack Compose UI element state and logic: local remember state, hoisted composable parameters, a plain state holder class, or a screen-level ViewModel/component, to keep UI simple and maintainable.

Core Features & Use Cases

  • Provides a structured decision framework for hoisting state in Compose applications, improving readability and testability.
  • Offers patterns for plain state holders and remember-based state to separate UI rendering from state management.
  • Guides when to introduce screen-level state holders (e.g., ViewModel) for business logic and data handling.

Quick Start

Follow this guide when starting a new Compose screen by identifying local state first and hoisting only as needed.

Frequently Asked Questions about compose-state-hoisting

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

FAQPage Schema
How do I hoist state in Jetpack Compose correctly?

Hoist Jetpack Compose state by moving UI element state and logic to the correct scope, from local remember state to hoisted composable parameters, keeping UI simple, testable, and stateless.

When should I use a ViewModel vs remember state in Compose?

Use a ViewModel for screen-level business logic and data handling, while local remember state or plain state holders manage UI-only state. Screen-level state holders ensure safe, testable UI state management.

What is a plain state holder class in Compose?

A plain state holder class in Compose separates UI rendering from state management. It manages hoisted state and logic for composables when state complexity outgrows local remember but doesn't require a ViewModel.

How do I structure state management for multi-screen Compose flows?

For multi-screen Compose flows, hoist state to the correct scope using plain state holders or screen-level ViewModels. This structured decision framework ensures readability, testability, and safe UI state across screens.

Why does my Compose UI state reset on configuration change?

Local remember state in Compose resets on configuration change. Hoist state to plain state holders or screen-level ViewModels to persist UI state and business logic safely across lifecycle events.

Do I need a ViewModel for simple Compose UI components?

No, simple Compose UI components can use local remember state or plain state holders. Introduce a ViewModel only when business logic, data handling, or screen-level state management is required for testability.