I'm trying to test it with functional components, but don't seem to notice any effect.
import { useEffect, useState } from 'react';
// @ts-ignore
import debounceRender from 'react-debounce-render';
export function Debounce() {
const [counter, setCounter] = useState(0);
useEffect(() => {
window.requestAnimationFrame(() => {
setCounter(counter + 1);
});
});
return <p>{counter}</p>;
}
export default debounceRender(Debounce, 1000, { maxWait: 1000 });
In my tests it keeps counting every frame. Desired effect: counting once per second. Using React 17.0.1.
What's wrong?
I'm trying to test it with functional components, but don't seem to notice any effect.
In my tests it keeps counting every frame. Desired effect: counting once per second. Using React 17.0.1.
What's wrong?