我在尝试将Invariant Violation: addComponentAsRefTo(...)
添加到我的组件集合时收到ReactCSSTransitionGroup
错误。
我的父渲染功能如下:
var notes = this.props.notes.reverse().map(function (v) {
return <NoteItem note={v} key={v.id} />;
});
return (
<div className="note-container">
<ReactCSSTransitionGroup transitionName="example" >
{notes}
</ReactCSSTransitionGroup>
</div>
);
Note
组件的渲染函数返回:
return (
<div>
<div className={classNames} onClick={this._onClick}>
{note.text}
</div>
{ showDetails ? <NoteItemDetails note={note} /> : null }
</div>
);
NoteItemDetails
组件可能与此无关。
完整的错误消息是:
Uncaught Error: Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. This usually means that you're trying to add a ref to a component that doesn't have an owner (that is, was not created inside of another component's 'render' method). Try rendering this component inside of a new top-level component which will hold the ref.
任何解决方案,可能会帮助我解决这个问题?