直接上代码,app.jsx:
import React from 'react'
import Text1 from './Textarea1.jsx'
import Text2 from './Textarea2.jsx'
var ReactCSSTransitionGroup = require('react-addons-css-transition-group');
export default React.createClass({
getInitialState:function(){
return{show:false}
//console.log(this.props);
},
addItem:function(){
this.setState({show:!this.state.show});
},
render: function() {
//console.log(this.state);
if(this.state.show)
{return (
<div>
<ReactCSSTransitionGroup transitionName="example" transitionEnterTimeout={5000} transitionLeaveTimeout={3000}>
<Text1/>
</ReactCSSTransitionGroup>
<button onClick={this.addItem}>增加</button>
</div>
);}
else
{
return (
<div>
<ReactCSSTransitionGroup transitionName="example2" transitionEnterTimeout={5000} transitionLeaveTimeout={3000}>
<Text2/>
</ReactCSSTransitionGroup>
<button onClick={this.addItem}>增加</button>
</div>
);
}
}
})
通过上述例子主要想看ReactCSSTransitionGroup什么时候会触发动画。设置state的做法不建议那样
2024 - 快车库 - 我的知识库 重庆启连科技有限公司 渝ICP备16002641号-10
企客连连 表单助手 企服开发 榜单123