Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
mobile ruleP1stack specificStack: android
androidcomposestate-hoisting
Hoist state out of composables; keep them stateless
A reusable composable should take state + callbacks as parameters, not own mutable state, so it stays testable and reusable.
PR: mobile-canon-2026-06Created: Jul 5, 2026
Bad example
Old codekotlin
| 1 | @Composable fun Counter() { var n by remember { mutableStateOf(0) } } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codekotlin
| 1 | @Composable fun Counter(n: Int, onInc: () -> Unit) |
Explanation (EN)
Objašnjenje (HR)