How can I animate a react.js component onclick and detect the end of the animation

后端 未结 6 1496
孤街浪徒
孤街浪徒 2020-12-28 13:19

I want to have a react component flip over when a user clicks on the DOM element. I see some documentation about their animation mixin but it looks to be set up for \"enter\

6条回答
  •  攒了一身酷
    2020-12-28 13:48

    React uses synthetic events, which includes animation events. Documention found here: https://reactjs.org/docs/events.html#animation-events. I updated the accepted answer below:

    class ClickMe extends React.Component {
      state = {fade: false};
    
      render () {
        const {fade} = this.state;
    
        return (
          
        )
      }
    }
    

提交回复
热议问题