Function consecuit::executor::run_later[][src]

pub fn run_later(f: impl FnOnce() + 'static)
Expand description

Schedule the given closure to run after the current component finishes rendering.

Example use to focus a consecuit_html’s input field:

use consecuit_html::prelude::*;
let (cc, input_ref) = cc.hook(use_ref, ());
let (cc, _) = cc.hook(use_effect, (|input_ref: Reference<Option<web_sys::HtmlInputElement>>| {
    run_later(move || {
        input_ref.visit_with(|opt| opt.as_ref().unwrap().focus().unwrap()).unwrap();
    })
}, input_ref.clone()))
cc_tree!(
    <input html_props().reference(input_ref) />
)