What problem does it solve?
Traditional custom modifiers in Compose often rely on Modifier.composed { }, which allocates a new composable scope on every recomposition and prevents hoisting, leading to poorer performance. This skill provides a migration path to Modifier.Node, enabling persistent nodes with in-place updates and explicit lifecycle management for draw, layout, semantics, and input behaviors.
Core Features & Use Cases
- Convert Modifier.composed factories into data class Elements and Node implementations.
- Leverage specialized interfaces like DrawModifierNode, LayoutModifierNode, SemanticsModifierNode, PointerInputModifierNode, CompositionLocalConsumerModifierNode, and more to express behaviors.
- Use onAttach/onDetach/onReset and the built-in coroutineScope to manage lifecycles and async work.
- Control invalidation with shouldAutoInvalidate and explicit invalidateDraw/invalidateMeasurement/invalidatePlacement.
- Support multi-behavior modifiers via DelegatingNode, reducing single-node complexity.
Quick Start
Identify every Modifier.composed factory in the module and replace it with a data class Element and a Node implementing the corresponding interfaces.