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();

let handle_click = use_callback({
  let mut transition = transition.clone();

  move |_| {
    let mut count = count.clone();

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

h!(div).build(c![
  transition.is_pending().then(||
    h!(div).build(c!["Loading…"])
  ),
  h!(button).on_click(&handle_click).build(c![]),
])