Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React CSS transitions group-使用post CSS和CX时如何设置类名?_Css_Reactjs_Css Transitions_React Transition Group - Fatal编程技术网

React CSS transitions group-使用post CSS和CX时如何设置类名?

React CSS transitions group-使用post CSS和CX时如何设置类名?,css,reactjs,css-transitions,react-transition-group,Css,Reactjs,Css Transitions,React Transition Group,这是我的密码: import styles from 'styles.css'; // other code render() { return <CSSTransition classNames= {{ enter: 'example-enter', enterActive: 'example-enter-active', exit: 'example-leave',

这是我的密码:

import styles from 'styles.css';
// other code

render() {
    return <CSSTransition
            classNames= {{
            enter: 'example-enter',
            enterActive: 'example-enter-active',
            exit: 'example-leave',
            exitActive: 'example-leave-active'
           }}
           in={true}
           timeout={300}
           onEnter = { () => console.log('mounting') }
           unmountOnExit
           >
           <div className={styles['someclass']}>Will animate</div>
           </CSSTransition>
}
从“styles.css”导入样式;
//其他代码
render(){
返回console.log('mounting')}
无关联
>
将生动活泼
}
如何使用样式数组在转换组上设置类?我尝试过将类设置为
style['example-enter'],style['example-leave']
等,但没有成功。此外,我的OneNet处理程序不工作


注意:对于转换来说是
classNames
,对于CX来说是
className
,因此它不是一个打字错误。

在CSTranslation中尝试以下操作:

classNames='example'
在css中:

.example-enter {}
.example-enter-active {} ...

我最终使用了
Transition
。问题是需要切换
in
值,将其设置为
true
总是不起作用。我认为同样的原则也应该适用于CSTranslation

// I am toggling animationProps.in based on some custom logic
<Transition
 in={this.state.animationProps.in}
 timeout={this.state.animationProps.duration}
 onExited={this.animationEnd}>
    {state => (
        <div style={{
          ...this.state.animationProps.defaultStyle,
          ...this.state.animationProps.transitionStyles[state]
        }}>
            My markup will go here.
        </div>
      )} 
</Transition>
//我正在根据一些自定义逻辑切换animationProps.in
{state=>(
我的标记将放在这里。
)}