google-map-react / old-examples

Examples for google-map-react component.
http://google-map-react.github.io/google-map-react/map/main/
357 stars 316 forks source link

addComponentAsRefTo() error because google_map.js loads a second copy of React #4

Open jedwards1211 opened 8 years ago

jedwards1211 commented 8 years ago

I'm getting this error: Uncaught 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'srendermethod). Try rendering this component inside of a new top-level component which will hold the ref.

Somehow the GoogleMap component was loading a second copy of React. I think it's similar to what these people are seeing: https://github.com/facebook/react/issues/3320

I had to use the PrefetchPlugin on react to get google-map-react to work. Maybe the rest of my code was loading plain old 'react' and GoogleMap is loading 'react/addons', but in any case I think it would help other developers new to google-map-react to have a note about this.