Kos*_*ika 0 javascript animation css-transitions reactjs reactcsstransitiongroup
我正在尝试添加动画,以便在React.js应用程序(http://facebook.github.io/react/docs/animation.html)中输入我的列表.
但ReactCSSTransitionGroup抛出这样的例外:
Uncaught TypeError: Cannot read property '_mockedReactClassConstructor' of undefined
连同警告:
Warning: React.createElement: type should not be null or undefined. It should be a string (for DOM elements) or a ReactClass (for composite components).
warning.js:36
Warning: Only functions or strings can be mounted as React components.
我的组件看起来像:
var List = React.createClass({
render: function () {
var items = this.props.data
.filter(function (item) {
return item.stream;
})
.map(function (item) {
return <div key={item.id}>item.name</div>;
});
return (
<div className="list clearfix">
<ReactCSSTransitionGroup transitionName="example">
{items}
</ReactCSSTransitionGroup>
</div>
);
}
});
Run Code Online (Sandbox Code Playgroud)
由于最初的答案是基于上述代码是正确的假设,这里是修改后的代码,基于你的小提琴.
在你的小提琴中,你没有参考ReactCSSTransitionGroup.你把它称为React.ReactCSSTransitionGroup,当然是undefined.这就是为什么你的小提琴会抱怨,如果你试图在其中包装任何东西,因为你使用的是未定义的值.为了让你的小提琴工作,你将不得不像这样引用css过渡组:
var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
Run Code Online (Sandbox Code Playgroud)
纠正的小提琴:http://jsfiddle.net/r98d348f/4/
| 归档时间: |
|
| 查看次数: |
5859 次 |
| 最近记录: |