I'm getting [Violation] 'setInterval' handler took <N>ms
message in browser console.
What does this indicate ?
How can I make below code better to avoid this warning message.
React code is -
function PopularBrands() {
const [slideIndex, setSlideIndex] = useState(1);
useEffect(() => {
console.log("useEffect");
const paginate = () => {
setSlideIndex((index) => {
console.log(index);
if (index === 4) {
return 1;
} else {
return index + 1;
}
});
};
const interval = setInterval(paginate, 3000);
return () => clearInterval(interval);
}, []);
return ...
}