Im trying to play around with ReactCssTransition but somehow the event is not called(componentWillLeave)
Here's my component
import React, { Component } from 'react'
import TransitionGroup from 'react-addons-css-transition-group'
export default class TransitionComponent extends Component {
constructor(props) {
super(props);
}
render() {
return (
let {componentKey} = this.props
<TransitionGroup transitionName="example" transitionEnterTimeout={500} transitionLeaveTimeout={500}>
<Item key={"item"+componentKey} />
</TransitionGroup>
);
}
}
And the child component
class Item extends Component {
componentDidEnter() {
console.log("component did enter");
}
componentWillLeave(callback) {
console.log("component will leave");
}
render() {
return (
<div>Item</div>
)
}
}
Any clue? Thanks!
I had similar issue caused by not calling the callback within the "componentWillEnter" function. Quote from React documentation
It will block other animations from occurring until callback is called
class Item extends Component {
componentWillEnter(callback) {
console.log("component will enter");
callback();
}
componentDidEnter() {
console.log("component did enter");
}
componentWillLeave(callback) {
console.log("component will leave");
callback();
}
render() {
return (
<div>Item</div>
)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With