I have a library called, 'myLib' that has several react components, comp1,..,compn, that i want to be able to import to another project.
The folder structure goes as
|_Components
|_ Comp1.js
|_ Comp2.js
|_ Comp3.js
|_index.js
Currently inside the index.js i have
exports.Comp1 = require('./components/comp1');
exports.Comp2 = require('./components/comp2');
exports.Comp3 = require('./components/comp3');
And inside the project i'm importing 'myLib', i'm doing so by
import myLib = require('myLib');
and to use the react components 'Comp1', inside the 'myApp' 's render(), i do
<myLib.Comp1></myLib.Comp1>
But 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's `render` method). Try rendering this component inside of a new top-level component which will hold the ref.
A little bit of googling suggest react is being referenced twice. Once inside the Comp1 and the 2nd time inside 'myApp' who's using Comp1.
My question is, am i doing this right? and how to fix the error i'm getting.
Edit:
After reading the bundle.js that comes from 'myApp' it does seem like react is being referenced twice. My question now is how do i get rid of it. I'm using browserify.