React ERROR: Refs Must Have Owner - ythy/blog GitHub Wiki
Warning: Element ref was specified as a string (myRefName) but no owner was set. You may have multiple copies of React loaded.
This usually means one of two things:
- You are trying to add a ref to an element that is being created outside of a component’s render() function.
- You have multiple (conflicting) copies of React loaded (eg. due to a misconfigured npm dependency)
报错实例:
function(){
render(
<div className="u-toast-fixed" >
<div className="u-toast-content" ref="tip">
{text}
</div>
</div>
)
}
改善方式:
function(){
render(
<div className="u-toast-fixed" >
<div className="u-toast-content" ref={c=>this.utip = c}>
{text}
</div>
</div>
)
}