Sebastian With this I get the error: TypeError: Cannot read property 'language' of undefined after 1 second. this.props.language is working in the constructor. But not in timer. Idk what's wrong. Let's see what you get in 2h+/-. ;)
export default class About extends React.Component {
constructor(props) {
super(props);
this.state = {
arr: this.props.language.about.style[0]
};
this.timer = this.timer.bind(this);
}
timer() {
let i = 0;
setInterval( function() {
this.setState({
arr: this.props.language.about.style[i]
});
i++;
if (i === this.props.language.about.style.length) {
i = 0;
}
}, 1000);
}
componentDidMount() {
this.timer();
}
render() {
return (
<div>{this.state.arr}</div>
);
}
}