反应cssTransitionGroup不添加类

时间:2019-01-22 09:33:29

标签: reactjs reactcsstransitiongroup

我的ReactCSSTransitionGroup在进入和离开时没有添加CSS类。我已将密钥添加到我的孩子们中,所以我想这可能是问题所在:

import React from 'react'
import ReactDOM from 'react-dom'
import ReactCSSTransitionGroup from 'react-addons-css-transition-group'

class Portal extends React.Component {
  constructor(props) {
    super(props)
    this.el = document.createElement('div')
   }

  componentDidMount() {
    document.body.appendChild(this.el)
  }

  componentWillUnmount() {
   document.body.removeChild(this.el)
  }

  render() {
    return ReactDOM.createPortal(
      this.props.children,
      this.el,
    )
  }
}

export default (props) =>
  <ReactCSSTransitionGroup
    transitionName='fade' //Fade not being added
    transitionAppear={true}
    transitionAppearTimeout={2000}
    transitionEnterTimeout={2000}
    transitionLeaveTimeout={300}
    component='div'>
    <Portal key={857985785} children={props.children} />
  </ReactCSSTransitionGroup>

我尝试过不将门户包裹在CSStransit元素中,但是仍然无法正常工作。

0 个答案:

没有答案