I'm trying to convert react function to react class
const prevSplash = () => {
if (index === 1) {
setIndex(0);
} else {
setIndex(prev => prev - 1);
}
}
const [index, setIndex] = React.useState(0);
React.useEffect(() => {
const timer = setInterval(() => {
if (index === 1) {
setIndex(0);
} else {
setIndex(prev => prev + 1);
}
}, 10000);
return () => clearInterval(timer);
},);