novdom/state/component

Functions

pub fn if1(
  state state: State(a),
  when should_show: fn(a) -> Bool,
  then component: Component,
) -> Component

Shows or hides the given component based on the result of the should_show function.

pub fn ternary1(
  state state: State(a),
  when should_show: fn(a) -> Bool,
  then component1: Component,
  otherwiese component2: Component,
) -> Component

Switches between the two given components based on the result of the should_show function.

pub fn utilize(
  state: State(a),
  do: fn(a) -> Component,
) -> Component

Rerenders the component using the do function on every state change.

Attention: Use this function only as a last resort. Prefer if(..) or ternary(..) instead. To display every item of a list, use novdom/state/list.map(..).
All named alternatives are way more performant.

Search Document