Material UI 5:如何知道折叠过渡何时完成?

Ser*_*eyn 9 javascript browser animation reactjs material-ui

我的代码

    <Collapse
      in={expanded}
      onTransitionEnd={() => console.log('finished')}
    >
        <div>foo</div>
    </Collapse>
Run Code Online (Sandbox Code Playgroud)

怎么了

折叠动画完成时不会调用回调(onTransitionEnd)。

我应该怎么做?

fer*_*r0n 3

我还期望addEndListenerCollapse API )在动画之后触发,但事实并非如此。与 Sereyn 的答案类似,这对我有用:

      <Collapse
        onEntered={() => console.log("expand animation done")}
        onExited={() => console.log("collapse animation done")}
        in={checked}
      >
        {icon}
      </Collapse>
Run Code Online (Sandbox Code Playgroud)