pink/state

Types

A reference to a state value in a React component.

pub type State(a)

Functions

pub fn get(state: State(a)) -> a

Get the current value of a state.

pub fn init(value value: a) -> State(a)

Initialize a stateful value.

This is a React hook. Read more about it on react.dev docs

Note: This hook is here for convenience, so you don’t have to create the bindings yourself

pub fn set(on state: State(a), value value: a) -> Nil

Set the value of a state.

pub fn set_with(
  on state: State(a),
  with setter: fn(a) -> a,
) -> Nil

Update the value of a state using a function.

Search Document