unmount/leave 时动画 React 组件

Animate React component when unmount/leave

我想在组件离开时使用 Velocity 淡出组件。我正在调用回调,但没有动画。下面的代码有什么问题?

export class Foo extends Component {

      componentWillEnter(cb) {
        cb();
      }

      componentWillLeave(cb) {
         const node = findDOMNode(el);
         Velocity(node, { opacity: 0 }, { duration:200 });
         cb();
      }
}

GSAP post 上找到它。回调需要作为完整的函数传递给 Velocity。

    export class Foo extends Component {
      componentWillEnter(cb) {
        cb();
      }
      componentWillLeave(cb) {
         const node = findDOMNode(el);
         Velocity(node, { opacity: 0 }, { duration:200, complete: cb });
      }

    ...
    }