Being new to React I have this question - I have two react components , the parent component is:
class Container extends Component {
render(){
if(!this.props.someProps){
return (
<div className="container-text">
<Intro />
</div>
)
} else {
return(
<div className="container-text">
Some text
</div>
)
}
}
}
The parent renders child component based on some prop. The child Component is:
export default class Intro extends Component{
constructor(props){
super(props)
this.state={
animated: false
}
}
componentDidMount(){
this.setState({
animated:true
})
}
render(){
return(
<CSSTransition
in={this.state.animated}
timeout={1000}
classNames='fade'>
<div>
<div className='intro-text'>
<p>choose</p>
<p>the</p>
<p>situation</p>
</div>
</div>
</CSSTransition>
)
}
}
I do get the fade animation when the component initially mounts, but i don't understand how i can animate it when it leaves the DOM ( so basically when this.props.someProps is true and just plain text is rendered in the Container class) ?