我正在尝试为我的 React 应用程序创建模态窗口,并且我正在关注本教程。
但是,我收到以下错误
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of `Modal`.
这是我的代码
import React from 'react'
import {ReactCSSTransitionGroup} from 'react-addons-css-transition-group'
const Modal = React.createClass ({
render() {
if (this.props.isOpen) {
return (
<ReactCSSTransitionGroup transitionName={this.props.transitionName}>
<div className="modal">
{this.props.children}
</div>
</ReactCSSTransitionGroup>
)
}
else {
return (
<ReactCSSTransitionGroup transitionName={this.props.transitionName} />
)
}
}
})
module.exports = Modal
我安装了 react-addons-css-transition-group 通过npm install --save react-addons-css-transition-group
问题显然是 ReactCSSTransitionGroup 没有正确导入,因为用普通 div 替换它不会引发任何错误。