Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Integrate ReactCssTransitionGroup with animate.css?

I am just Trying to Integrate animate.css with react transition group.Yes I know there is already one question is there.But that is no more working.I need a working example. This is my Try

<ReactCSSTransitionGroup transitionName={{enter: "animated", enterActive: "bounce", leave: "animated",leaveActive: "tada"}}>
    {this.props.children}
</ReactCSSTransitionGroup>
like image 850
vignesh waran Avatar asked Jul 02 '16 04:07

vignesh waran


1 Answers

example: animate.css with react transition group Jsfidle

class App extends React.Component {
    constructor(props){
        super(props);
        this.state={items: ['hello', 'world', 'click', 'me']};
    }
    handleAdd() {
        let {items} = this.state
        this.setState({items: [...items, 'new-element'+(items.length+1)]});
    }
    handleRemove(i) {
        var newItems = this.state.items.slice();
        newItems.splice(i, 1);
        this.setState({items: newItems});
    }
    render() {
        var items = this.state.items.map((item, i)=>
        <div key={item} className="block" onClick={this.handleRemove.bind(this, i)}>
        {item}
        </div>
    );
    return (
        <div>
        <button onClick={this.handleAdd.bind(this)}>Add Item</button>
        <CSSTransitionGroup
        transitionName={{
            enter: "animated",
            enterActive: "rubberBand",
            leave: "animated",
            leaveActive: "fadeOutRight"
        }}>
        {items}
        </CSSTransitionGroup>
        </div>
    );
}


}
like image 138
Kokovin Vladislav Avatar answered Oct 13 '22 11:10

Kokovin Vladislav