在我以前的Meteor應用程序中,使用browserify和React,所有工作都在工作,直到我切換到meteor webpack。如何防止加載多個副本的反應?
我用我的流星應用react-select和它的工作很好,但與browserify我能阻止反應的多個副本加載因而避免了這種錯誤,現在我有:
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).
我的package.json看看這個:
...
"dependencies": {
"classnames": "^2.1.3",
"lodash": "^3.10.0",
"react": "^0.14.6",
"react-dom": "^0.14.6",
"react-mixin": "^2.0.1",
"react-select": "^1.0.0-beta8"
},
...
有沒有在webpack中的配置我可以使用一些調用外部的東西?不能完全肯定這意味着什麼,但評論說,使用方法:
externals: {
'react': 'React',
'react-dom': 'ReactDOM'
}
看起來像使用反應的多個版本。 stackoverflow.com/questions/34236426/how-to-fix-react-error-uncaught-error-invariant-violation-addcomponentasrefto/34358537#34358537 – Manivannan