Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

qwik js clear interval

export const Child = component$(() => {
    const state = useStore({
        count: 0
    });

    // Double count watch
    useClientEffect$(() => {
        const timer = setInterval(() => {
        state.count++;
        }, 1000);
        return () => {
        clearInterval(timer);
        }
    });

    return (
        <div>
        {state.count}
    </div>
    );
});
Source by learn.coderslang.com #
 
PREVIOUS NEXT
Tagged: #qwik #js #clear #interval
ADD COMMENT
Topic
Name
8+6 =