sprocket/component

Types

Context used by stateful components.

pub type Context =
  context.Context

Element that can be rendered

pub type Element =
  context.Element

A StatefulComponent is a component that has an associated state, lifecycle and takes props as input.

pub type StatefulComponent(p) =
  context.StatefulComponent(p)

Functions

pub fn component(
  c: fn(Context, a) -> #(Context, Element),
  props: a,
) -> Element

Creates a new stateful component element from a given component function and props.

pub fn provider(
  key: String,
  value: a,
  element: Element,
) -> Element

Creates a new provider element with the given key and value.

pub fn render(
  ctx: Context,
  element: Element,
) -> #(Context, Element)

Renders an element with the given context.

Search Document