This is my component, with ref
import React, { Component } from 'react';
export default class Comp1 extends Component {
render() {
return (
<span >
<span ref="someRef">
<input type='text'/>
</span>
</span>
);
}
which responds as expected on development env, but when I build with production
env, then the following error comes
invariant.js:38 Uncaught Invariant Violation: 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 (details: https://facebook.github.io/react/warnings/refs-must-have-owner.html).
I am really stuck with this error. Has anyone faced similar issue?? With react v15.0.1
According to official documentation for this error, there can be two reasons, Invalid Refs and Multiple copies of react.
Here is my npm ls react
└── react@15.2.1
And, the following is npm ls | grep react