Fix eventhandler optional (#2119)

This commit is contained in:
Jonathan Kelley 2024-03-20 09:04:37 -07:00 committed by GitHub
parent 9f283f571f
commit 44e997f7df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions

View file

@ -24,9 +24,7 @@ enum Route {
#[component]
fn Homepage() -> Element {
rsx! {
h1 { "Welcome home" }
}
rsx! { h1 { "Welcome home" } }
}
#[component]
@ -52,6 +50,7 @@ fn Nav() -> Element {
to: Route::Blog {
id: "Brownies".to_string(),
},
onclick: move |_| { println!("Clicked on Brownies") },
"Learn Brownies"
}
}

View file

@ -170,6 +170,17 @@ impl<'a> SuperFrom<Arguments<'a>, OptionArgumentsFromMarker> for Option<String>
}
}
#[doc(hidden)]
pub struct OptionHandlerMarker;
impl<G: 'static, F: FnMut(G) + 'static> SuperFrom<F, OptionHandlerMarker>
for Option<EventHandler<G>>
{
fn super_from(input: F) -> Self {
Some(EventHandler::new(input))
}
}
#[test]
#[allow(unused)]
fn from_props_compiles() {