I am implementing a feature where a component changes at regular time intervals.
Is there a way to incorporate an animation each time this change occurs? What would be the most effective approach?
constructor (props) {
super(props)
this.state = { currentComponent: 1,
numberOfComponents: 2}
}
componentWillMount() {
setInterval(() => {
if(this.state.currentComponent === 2) {
this.setState({currentComponent: 1})
} else {
this.setState({currentComponent: this.state.currentComponent + 1})
}
}, 5000)
}
render(){
let currentComponent = null;
if(this.state.currentComponent === 1) {
currentComponent = <ComponentOne/>;
} else {
currentComponent = <ComponentTwo/>;
}
return(
currentComponent
)
}
UPDATE:
In addition, I encountered an issue when attempting to utilize 'react-addons-css-transition-group', resulting in the following error: