我發現了一個Invariant Violation: addComponentAsRefTo(...)
錯誤,而試圖添加ReactCSSTransitionGroup
到我的收藏組件。在自定義成分發生化學反應CSS過渡小組
我的父母渲染功能看起來像:
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
組件可能是unrelevant那裏。
完整的錯誤信息是:
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.
的任何解決方案,這可能會幫助我解決這個問題?