【发布时间】:2015-03-26 00:50:12
【问题描述】:
我将react-rails 与Fluxxor 和React 一起使用。只要我停留在同一页面上,我的组件就可以完全正常工作。
但是,如果我通过单击其他链接更改页面并返回到我的组件,当我尝试在其上使用 setState 时,它会抛出错误:
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.
我的实际代码可以在here 找到。问题似乎是setState 方法here。也许我的Chosen 组件的refs 属性不能重新渲染?可能是Turbolink引起的?
【问题讨论】:
标签: javascript ruby-on-rails reactjs