pub fn use_transition() -> Transition
Expand description

Returns a stateful value for the pending state of the transition, and a function to start it.

Example

let count = use_state(|| 0);
let transition = use_transition();

h!(div).build((
  transition.is_pending().then(||
    h!(div).build("Loading…")
  ),
  h!(button).on_click(&callback!(clone(mut transition), move |_| {
    let mut count = count.clone();

    transition.start(move || {
      count.set(|c| c + 1);
    });
  })).build(()),
))