I have created a react component which consist of slideUp() and slideDown() animation. I have implemented using jQuery slideup and slidedown methods.
I have to implement this feature using react animation.
I read about ReactTransitionGroup and ReactCSSTransitionGroup. The way of explanation taught me, we can do this functionality when DomNode mounted to a component or unmount(Correct me if I am wrong).
My question is --> how to do slideup() and slidedown() in react way and without using jQuery.
See this jsFiddle for https://jsfiddle.net/guc3yrm1/
P.S - > Please explain me why this react animation part seems bit a difficult when compare to jQuery(I am a jQuery guy)
var Hello = React.createClass({
getInitialState: function() {
return {
slide: false,
}
},
slide: function() {
if (this.state.slide) {
$(this.refs.slide).slideDown();
this.setState({
slide: false
});
} else {
$(this.refs.slide).slideUp();
this.setState({
slide: true
});
}
},
render: function() {
return (
<div>
<input type = "button" value = "clickme" onClick = {this.slide}/>
<br />
<br />
<div className = "slide" ref="slide" >< /div>
</div>
);
}
});
ReactDOM.render( < Hello name = "World" / > ,
document.getElementById('container')
);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…