jetli/yew-hooks

unexpected behavior of use_debounce

jgraydus opened this issue · 0 comments

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();
}