CSSTransition:- React.Children.only 预期接收单个 React 元素子元素

CSSTransition:- React.Children.only expected to receive a single React element child

在我的代码下面。 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;

两件事:

  1. 确保实际安装react-transition-group
  2. 不带花括号导入