【发布时间】:2025-12-17 11:25:01
【问题描述】:
在我的代码下面。 CSSTransition 未被识别。由于某种原因,它会引发错误。我尝试了带大括号和不带大括号的导入,但似乎都不起作用。
import React, { Component } from 'react';
import styles from '../stylesheets/style.module.css';
import { CSSTransition } from 'react-transition-group';
class SlideShow extends Component {
state = {
backgroundColor: 'white',
changePic: true,
slideIndex: 1,
};
render() {
return (
<div className={styles.slideshowContainer}>
<CSSTransition
in={this.state.changePic}
timeout={{
enter: 2000,
exit: 800,
}}
classNames="slidePics"
unmountOnExit={true}
></CSSTransition>
</div>
);
}
}
export default SlideShow;
【问题讨论】:
-
它到底抛出了什么错误?
-
元素类型无效:应为字符串(用于内置组件)或类/函数(用于复合组件),但得到:未定义。 - 它说。当我删除 CSSTransition 时,它工作正常
标签: reactjs react-transition-group