Function use_hovered

Source
pub fn use_hovered<'hook>(node: NodeRef) -> impl 'hook + Hook<Output = bool>
Expand description

A sensor hook that tracks whether HTML element is being hovered.

§Example

use yew_hooks::prelude::*;

#[function_component(UseHovered)]
fn hovered() -> Html {
    let node = use_node_ref();
    let state = use_hovered(node.clone());

    html! {
        <div ref={node}>
            <b>{ " Hovered: " }</b>
            { state }
        </div>
    }
}

§Note

When used in function components and hooks, this hook is equivalent to:

pub fn use_hovered(node: NodeRef) -> bool {
    /* implementation omitted */
}