Im looking at examples about how to use TransitionGroup addon, but all the examples I can find are with class components and quite old articles. For example, how would you refactor this class component to an ES6 functional component and using the correct ReactTransitionGroup hooks to achieve the same?
class Box extends React.Component {
componentWillEnter (callback) {
const el = this.container;
TweenMax.fromTo(el, 0.3, {y: 100, opacity: 0}, {y: 0, opacity: 1, onComplete: callback});
}
componentWillLeave (callback) {
const el = this.container;
TweenMax.fromTo(el, 0.3, {y: 0, opacity: 1}, {y: -100, opacity: 0, onComplete: callback});
}
render () {
return <div className="box" ref={c => this.container = c}/>;
}
}
How to call componentWillEnter
and componentWillLeave
hooks in a functional component?