Synphonyte / leptos-use

Collection of essential Leptos utilities inspired by React-Use / VueUse / SolidJS-USE
https://leptos-use.rs/
Apache License 2.0
309 stars 67 forks source link

trait not implemented #81

Closed j00p34 closed 7 months ago

j00p34 commented 7 months ago

O'm trying to use use_element_visibility:

let element = create_node_ref::<Div>();

let is_visible = use_element_visibility(element);

But I get the following error:

error[E0277]: the trait bound leptos::web_sys::Element: From<NodeRef<leptos::html::Div>> is not satisfied --> src/app.rs:28:45 28 let is_visible = use_element_visibility(element); ---------------------- ^^^^^^^ the trait From<NodeRef<leptos::html::Div>> is not implemented for leptos::web_sys::Element
required by a bound introduced by this call

= help: the following other types implement trait From<T>: <leptos::web_sys::Element as From> <leptos::web_sys::Element as From> <leptos::web_sys::Element as From> <leptos::web_sys::Element as From> <leptos::web_sys::Element as From> <leptos::web_sys::Element as From> <leptos::web_sys::Element as From> <leptos::web_sys::Element as From> and 59 others = note: required for NodeRef<leptos::html::Div> to implement Into<leptos::web_sys::Element> = note: required for ElementMaybeSignal<NodeRef<leptos::html::Div>, leptos::web_sys::Element> to implement From<NodeRef<leptos::html::Div>> = note: 1 redundant requirement hidden = note: required for NodeRef<leptos::html::Div> to implement Into<ElementMaybeSignal<NodeRef<leptos::html::Div>, leptos::web_sys::Element>> note: required by a bound in use_element_visibility --> /home/timothy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos-use-0.10.2/src/use_element_visibility.rs:46:9 | 44 | pub fn use_element_visibility<El, T>(target: El) -> Signal | ---------------------- required by a bound in this function 45 | where 46 | El: Into<ElementMaybeSignal<T, web_sys::Element>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in use_element_visibility

maccesch commented 7 months ago

This looks like you have a Leptos version mismatch somewhere. What version of leptos-use do you use and what version of leptos?

j00p34 commented 7 months ago

leptos-use = "0.10.2" leptos-0.6.5

That should work together shouldn't it? I'm trying to add it to the tailwind_axum example

maccesch commented 7 months ago

It should. Maybe try deleting your Cargo.lock and rebuild

j00p34 commented 7 months ago

Doesn't make a difference, I've uploaded the code here https://github.com/j00p34/tailwind_axum Maybe you can have a look?

maccesch commented 7 months ago

Hehe your code is not like you wrote in the error message. Try to change it to exactly that and it works

j00p34 commented 7 months ago

Yes, you're right thank's a lot. I've been messing around with it to fix that error. But in the code I was using previously I used leptos from a release I downloaded, where cargo was pointing to the local filesystem. I changed that to crates from the internet and I guess that fixed the problem. But I introduced a new error by my messing around. Well thank's a lot again, really appreciate your help.