I have a list of 5 images in my react app which I would like to cycle through in an infinite loop. I basically want to animate these 5 frames so that a light bar looks like a light that is constantly moving.
So the dot which shifts in each image will look as though it is moving.
I am currently importing each image and rendering it in react-bootstraps Image component. I know my approach is probably off below. How would I go about doing this accurately?
My attempts
//images
import bar1 from "../assets/bar1.png";
import bar2 from "../assets/bar2.png";
import bar3 from "../assets/bar3.png";
import bar4 from "../assets/bar4.png";
import bar5 from "../assets/bar5.png";
//my state
state = {
bars:[bar1,bar2,bar3,bar4,bar5]
};
//function to cycle (this needs to run infinitely)
cycleBars =()=> {
let finalBar = this.state.bars0];
//return this.state.bars[0];
this.state.bars.map(e=>{
finalBar = e;
})
return finalBar;
}
//return from my component
<Image src={this.cycleBars()} />
