react 问题记录

1、控制台报错:

Uncaught Error: 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

Uncaught Error: removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might be removing a ref to a component that was not created inside a component's `render` method, or you have multiple copies of React loaded

如果检查了没有refs的错误,那么就有可能是你引入了多个react版本,我的项目使用的是yarn, yarn list react看下:

yarn list v1.1.0
├─ com1@1.0.5
│ └─ react@0.14.8
├─ comp2@0.0.4
│ └─ react@0.14.8
├─comp3@1.0.2
│ └─ react@0.14.8
├─ comp4@1.2.1
│ └─ react@0.14.8
├─ comp5@1.2.0
│ └─ react@0.14.8
└─ react@0.14.9

项目下面安装了react14.8 又安装了14.9

所以会有问题

参考https://github.com/callemall/material-ui/issues/6345

posted @ 2017-10-18 12:05  爆炒小黄鸡  阅读(508)  评论(0编辑  收藏  举报