I simply can't seem to find the bug here? Why does the following code give me a "Cant perform react state update on an unmounted component"?
import React, {useState, useEffect} from 'react'
function LogoText(){
const[imgCount, setImgCount] = useState(0)
const imgTexts = [
"images/logo/LOGO_SDe.svg",
"images/logo/LOGO_SRe.svg",
"images/logo/LOGO_SRn.svg"
]
useEffect(() => {
const intervalId = setInterval(() => {
if(imgCount !== 2){
setImgCount(prevState => prevState + 1)
} else {setImgCount(0)}
}, 3000)
return () => clearInterval(intervalId);
}, [imgCount])
return(
<div className="imgText-container">
<img src={imgTexts[0]} alt='' className={imgCount === 0 ? "showImg" : null}/>
<img src={imgTexts[1]} alt='' className={imgCount === 1 ? "showImg" : null}/>
<img src={imgTexts[2]} alt='' className={imgCount === 2 ? "showImg" : null}/>
</div>
)
}