Lavash.Component.State (Lavash v0.3.0-rc.5)

Copy Markdown View Source

A state field that connects component state to parent state.

A state field that connects component state to parent state.

State fields are bound to parent LiveView state and can be modified through optimistic actions.

Fields

  • :name - The atom name of the state field
  • :type - The type specification (e.g., :boolean, {:array, :string})
  • :from - Storage location (:parent for components, default)
  • :default - Default value if not provided

Usage

In a Lavash.Component:

state :tags, {:array, :string}
state :active, :boolean, default: false

The state field will be bound to the parent's state of the same name via the bind prop.