pream

Types

typed component record — wraps a props-to-vnode render function so it can be named, composed, and passed around explicitly

pub type Component(p) {
  Component(render: fn(p) -> vnode.VNode)
}

Constructors

https://npmx.dev/package-docs/preact/v/10.29.2#class-ComponentChildren

pub type PreactComponent

Values

pub fn component(render: fn(p) -> vnode.VNode) -> Component(p)

construct a component from a render function

pub fn render_component(
  comp: Component(p),
  props: p,
) -> vnode.VNode

render a component with the given props

pub fn to_preact(from node: vnode.VNode) -> PreactComponent

https://npmx.dev/package-docs/preact/v/10.29.2#function-h converts a vnode tree into a preact ComponentChildren value, ready to pass to preact’s render()

pub fn to_preact_component(
  comp: Component(p),
  props: p,
) -> PreactComponent

render a component and convert directly to a preact component, ready for render()

pub fn unwrap(
  render component: fn(p) -> Result(vnode.VNode, b),
  with props: p,
) -> vnode.VNode

unwraps a Result-returning render function. an Error is silently coerced into an empty vnode — useful when a component is allowed to fail without taking down the whole tree

pub fn unwrap_option(
  render component: fn(p) -> option.Option(vnode.VNode),
  with props: p,
) -> vnode.VNode

unwraps an Option-returning render function. None is silently coerced into an empty vnode

pub fn use_computed(compute: fn() -> a) -> signal.Signal(a)

https://npmx.dev/package-docs/@preact%2Fsignals/v/2.9.1#function-useComputed returns a read-only computed signal scoped to a component — same semantics as signal.computed

pub fn use_signal(initial: a) -> signal.Signal(a)

https://npmx.dev/package-docs/@preact%2Fsignals/v/2.9.1#function-useSignal creates a reactive signal scoped to a component. returns the same Signal type as signal.new, composable with signal.value, signal.set, signal.map, etc.

pub fn use_signal_effect(run: fn() -> Nil) -> Nil

https://npmx.dev/package-docs/@preact%2Fsignals/v/2.9.1#function-useSignalEffect runs a reactive effect scoped to a component

Search Document