在自定义组件上反应CSS过渡组

时间:2015-09-19 12:42:05

标签: reactjs components transition

我在尝试将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.

任何解决方案,可能会帮助我解决这个问题?

0 个答案:

没有答案