Description
Let's say we have app called My-app managed by create-react-app and some library My-lib, being dependency of My-app. Both uses React.
Now, using npm-link gives us multiple copies of React in dependency tree, which ultimately (at least for me) ends with this error:
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://fb.me/react-refs-must-have-owner).
The only solution I've found (http://stackoverflow.com/a/31170775/2395401) was to define alias in webpack configuration like this:
resolve: {
alias: {
...
'react': path.resolve('./node_modules/react')
}
}
Of course this means ejecting project.
Isn't it good idea to place this alias in default config?