How to clear Interval after component unmount #2323
Answered
by
gbj
dvorakchen
asked this question in
Q&A
Replies: 1 comment 4 replies
-
#[component]
pub fn App() -> impl IntoView {
let (index, set_index) = create_signal(0);
let handle = Interval::new(500, move || {
set_index.update(|v| *v += 1);
// do something
});
on_cleanup(move || drop(handle));
view! {
.................
}
} |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
dvorakchen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I used the
Interval
from 'use gloo::timers::callback::Interval;',I hop I can clear the Interval after I do not need this component, but how to do it?
Beta Was this translation helpful? Give feedback.
All reactions