You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0277]: expected a `FnMut(leptos::ev::MouseEvent)` closure, found `leptos::prelude::Callback<leptos::ev::MouseEvent>`
--> packages/leptos/button/src/default.rs:114:5
|
114 | / view! {
115 | | <button on:click=on_click>
| | -- required by a bound introduced by this call
116 | | {children()}
117 | | </button>
118 | | }
| |_____^ expected an `FnMut(leptos::ev::MouseEvent)` closure, found `leptos::prelude::Callback<leptos::ev::MouseEvent>`
|
= help: the trait `FnMut(leptos::ev::MouseEvent)` is not implemented for `leptos::prelude::Callback<leptos::ev::MouseEvent>`, which is required by `leptos::html::HtmlElement<leptos::html::Button, (), (leptos::prelude::AnyView,)>: leptos::prelude::OnAttribute<_, _>`
= help: the trait `leptos::prelude::OnAttribute<E, F>` is implemented for `leptos::html::HtmlElement<El, At, Ch>`
= note: required for `leptos::html::HtmlElement<leptos::html::Button, (), (leptos::prelude::AnyView,)>` to implement `leptos::prelude::OnAttribute<leptos::ev::click, leptos::prelude::Callback<leptos::ev::MouseEvent>>`
Unfortunately this is working as designed. I have attempted to implement this in the past and not been successful. I'm open to a PR that successfully implements it directly.
I would recommend taking impl FnMut(MouseEvent) + 'static or a similar type for on_click in the examples above.
Describe the bug
Passing a
Callback
as listener gives an error:However, manually calling
.run()
works fine:Leptos Dependencies
Expected behavior
I would expect
Callback
to be accepted as is, without manually calling.run()
.It might be nice for
Option<Callback<T>>
to be accepted as well, so you can create an#[prop(into, optional)] on_click: Option<Callback<MouseEvent>>
.The text was updated successfully, but these errors were encountered: