Lifecycle and refs
Understand setup, mount identity, cleanup and the limits of native refs.
On this page
The Rust block initializes a mount
Top-level initialization in <rust> runs once when a component mounts. Typed let declarations become retained state fields. A child can read its incoming props during initialization; the generated State stores the latest values in state.props.
Construct state, Signals, Computed values and composables directly in this block. The default form needs no user-written setup function or setup lifecycle hook. Updating props or repainting a native frame does not rerun initialization for the same mount.
Identity controls lifetime
A retained component has an identity and generation. A keyed reorder preserves that identity. Removing the child unmounts it; old queued callbacks and owned task completions cannot mutate a later generation.
If the key changes, expect a new mount and fresh local state. Keep long-lived shared services outside a disposable child and provide them through Scope when appropriate.
Cleanup and tasks
Inrux tracks child-owned events and tasks. Unmounting invalidates their ownership. Task cancellation is cooperative; arbitrary Rust work does not stop by force. Check cancellation in long loops and avoid holding resources longer than the task needs them.
Rust ownership and Drop remain relevant. Current mount ownership is not a complete set of user-facing mounted/updated/unmounted hooks. Check exported APIs rather than copying lifecycle names from Vue.
Native component refs are planned
A Rust borrow, Signal handle or InstanceHandle is not a public native-widget ref. Generation-safe node refs, child targeting and animation commands are not available APIs today. Do not use an engine widget handle in a portable component to work around that boundary.
For current lifetime details, read the component contract and alpha status.
Use <rust explicit> when you want to author State and pub fn setup yourself. Plain <rust> uses automatic setup. Both forms initialize once per component mount.