-
I can use an This is the custom component: #[component]
pub fn MyComponent(onclick: Option<EventHandler<MouseEvent>>) -> Element {
rsx!(
a {
onclick: move |event| if let Some(handler) = onclick{ handler.call(event)},
}
)
} If I use it like this it compiles: MyComponent {
onclick: move |_| do_something()
} This violates some trait bounds in the MyComponent {
onclick: move |_| async move { do_something_async().await }
} |
Beta Was this translation helpful? Give feedback.
Answered by
Tahinli
Apr 7, 2024
Replies: 2 comments
-
This may help: let call_async = move |_| {
spawn({
async move {
do_something_async.await;
}
});
};
rsx!{
MyComponent {
onclick: call_async,
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
wackazong
-
Of course 🫣 Thanks. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This may help: