Tried sth but it's not working...
Hey. I've tried to create what you said. But I get an error. How can I call timer() inside componentDidMount? This whole code might be wrong. So I would be glad if you could help. :)
export default class About extends React.Component {
constructor(props) {
super(props);
this.state = {
arr: this.props.language.about.style[0]
};
}
timer() {
let i = 0;
function createTimer() {
this.setState({
arr: this.props.language.about.style[i]
});
i++;
if (i === this.props.language.about.style.length) {
i = 0;
}
}
setInterval(createTimer, 500);
}
componentDidMount() {
timer();
}
render() {
return (
<div>{this.state.arr}</div>
);
}
}