Skip to content

Commit

Permalink
Fix eventhandler optional (#2119)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkelleyrtp authored Mar 20, 2024
1 parent 9f283f5 commit 44e997f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 2 additions & 3 deletions examples/simple_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ enum Route {

#[component]
fn Homepage() -> Element {
rsx! {
h1 { "Welcome home" }
}
rsx! { h1 { "Welcome home" } }
}

#[component]
Expand All @@ -52,6 +50,7 @@ fn Nav() -> Element {
to: Route::Blog {
id: "Brownies".to_string(),
},
onclick: move |_| { println!("Clicked on Brownies") },
"Learn Brownies"
}
}
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 44e997f

Please sign in to comment.