Skip to content

unexpected behavior of use_debounce #39

Description

@jgraydus

It seems that use_debounce returns a callback in a triggered state. That is, after the given time elapses the original callback is invoked whether or not the debounced version was ever invoked. This is not the behavior that I would expect. Is this the desired behavior for this hook?

The following code demonstrates:

use gloo_console::log;
use yew::prelude::*;
use yew_hooks::use_debounce;

#[function_component(App)]
fn app() -> Html {
  let f = use_debounce(|| {
    log!("this should never print, but it does");
  }, 1000);

  html! {}
}

fn main() {
  yew::Renderer::<App>::new().render();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions