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=>(
我的标记将放在这里。
)}