0

I'm using the react-rails gem, and everything works fine until I press the back button of the browser and go to the previous page. I get the error below.

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

I get the same error when I press the back button of the browser, or go back a page with a keyboard press. Please help me out!

Novice
  • 575
  • 2
  • 7
  • 16
  • Are you using any 3rd party React packages? The version of React included in react-rails doesn't tend to cooperate well with third party React packages. I've ended up removing //= require react from my application.js and I manually load in the npm version instead. – Joe May 16 '16 at 21:39
  • I have `//= require react`, `//= require react_ujs`, `//= require react-bootstrap`. I did read somewhere that `react-bootstrap` has its own version of react included. – Novice May 16 '16 at 21:41
  • How do you manually load the npm version? Don't I eventually have to include react in `application.js`? – Novice May 16 '16 at 21:44
  • Possible duplicate of [React Error (Only a ReactOwner can have refs.)](https://stackoverflow.com/questions/37663175/react-error-only-a-reactowner-can-have-refs) – btzr Jul 28 '17 at 04:47

0 Answers0