EventHandler

Type Alias EventHandler 

Source
pub type EventHandler<T = ()> = Callback<T>;
Available on crate feature prelude only.
Expand description

The callback type generated by the rsx! macro when an on field is specified for components.

This makes it possible to pass move |evt| {} style closures into components as property fields.

§Example

rsx! {
    MyComponent { onclick: move |evt| tracing::debug!("clicked") }
};

#[derive(Props, Clone, PartialEq)]
struct MyProps {
    onclick: EventHandler<MouseEvent>,
}

fn MyComponent(cx: MyProps) -> Element {
    rsx! {
        button {
            onclick: move |evt| cx.onclick.call(evt),
        }
    }
}

Aliased Type§

pub struct EventHandler<T = ()> { /* private fields */ }