React-rails: Get issue: addComponentAsRefTo(...)

Created on 15 Mar 2017  路  5Comments  路  Source: reactjs/react-rails

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.

Got this error after upgrade gem to version 1.10.0. Old version (1.9.0) works correctly.

Most helpful comment

try to remove the line //= require react-server from javascripts/component/server_rendering.js and see if it helps.

All 5 comments

Are you adding a ref to a component that was not created inside a component's render method, or you have multiple copies of React loaded?

If you want to debug this, please share some info:

  • the source of the component which raises this error
  • how you load React.js into your app
  • anything else you tried to debug

Then reopen this issue when you add that information!

try to remove the line //= require react-server from javascripts/component/server_rendering.js and see if it helps.

Hi @pan , it does work for me though I am no idea why. Thank you.

I ran into this same issue. While removing react-server from server_rendering.js does stop the error, it breaks server-side rendering.

Since mine also broke on an upgrade, I discovered that the real issue was due to using the legacy api for string refs. Figured I'd add this in case it helps anyone else.

@pan it does solve my issue. Thanks a lot.

Was this page helpful?
0 / 5 - 0 ratings