I am using Meteor 1.3+ for making several applications, I use React rendering and NPM modules to setup the infrastructure, such us
react-router, etc; but at the same time and in order to promote modularity and reusability I am sharing React components in a separate Meteor package.
The infrastructure that I have posed may be depicted as:
Meteor App #1 NPM Package react Meteor Package A NPM Package react Meteor Package B NPM Package react Meteor App #2 NPM Package react Meteor Package A NPM Package react
I have used
npm install --save [module] in the applications and packages. But when I try to render components that are created in both applications and packages, I got the next React error:
Uncaught Error: 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://fb.me/react-refs-must-have-owner).
What is happening is that React is being instantiated several times, one per application and package. That unable me to use react references on components as those rely on a singleton React.
Do you know is there is a way to avoid a npm module to be instantiated more than one time? I have also tried to use
Npm.depends([modules]) on each package, but it happens the same.