私は、時間間隔でレンダリングされるコンポーネントを変更します。React:レンダリングされたコンポーネントの変更をアニメーション化する方法は?
変更が発生するたびにアニメーションを追加できます。それについて最善の方法は何ですか?
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
)
}
EDIT:
また、「反応-アドオン-CSS-遷移グループの を使用しようとすると、私は次のエラーを取得する:
私の意見では最も簡単にはCSS3トランジションを使用しています。要素にあなたの状態に基づいたクラスを与え、要素のスタイリングを変更します。 CSS3トランジション(またはCSS3アニメーション)を使用して、このスタイリングを変更することができます。 – stinodes