FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    rerender

    function · ferroui-view · v0.5.0

    fn rerender<F, E>(render: F) -> Element
    where F: Fn() -> E + 'static,
          E: IntoElement
    

    An element of a component that runs again: render runs when the element is mounted and again whenever a signal it read changes or the component that holds the element runs again; the elements it returns are compared with those of the run before and the controls are patched (docs/declarative-ui.md, section 8). State that outlives one run is kept in hooks.

    fn counter() -> Element {
        rerender(|| {
            let count = use_signal(|| 0);
            button()
                .content(format!("Clicked {} times", count.get()))
                .on_click(move |_| count.update(|c| *c += 1))
                .into()
        })
    }
    

    Two elements of rerender are the same component when their closures are of the same type: the same place in the code.

    View source

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.