(1)addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's `render` method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).

错误原因:没有将ref写成回调形式,出现报错;


import ReactDOM from 'react-dom';

handlerAddClick(e){ e.preventDefault();//阻止默认事件 let item = {};//单挑数据 let addForm = ReactDOM.findDOMNode(this.addForm); } render(){ return(
<div ref={(ref)=>this.addForm = ref }> <form className="footerAddd"></form>

(2)再配合ref使用findDOMNode错误

Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_0_react___default.a.findDOMNode is not a function

使用15.0以后的版本需要引入ReactDOM,如上面的所示。

posted on 2018-07-04 14:51  Anby-PBH  阅读(586)  评论(0编辑  收藏  举报