[英]prevent react from being bundled in my module so react can't exist twice
I am writing a npm package that depend on : 我正在写一个依赖于的npm软件包:
"peerDependencies": {
"react": "15.4.1",
},
"dependencies": {
"classnames": "2.2.5",
"react-onclickoutside": "5.8.3",
"styled-components": "1.1.2"
}
I have added them as peer dependencies. 我已将它们添加为对等依赖项。
I have created a webpack build, and I've generated a 'umd' module that I want to import in my application. 我已经创建了一个webpack构建,并且已经生成了一个要导入到我的应用程序中的“ umd”模块。
The probleme is that a component from the module that depend on react-onclickoutside, complain about the presence of 2 React. 问题在于依赖于react-onclickoutside的模块中的组件抱怨2 React的存在。
This is the code that can be toggled and generate this error : 这是可以切换并生成此错误的代码:
DropDown = onClickOutside(DropDown, {
handleClickOutside(instance) {
return instance.closeMenu;
},
});
This give me this error : 这给我这个错误:
Error: 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: ....).(…)
If I look at my UMD module, I can see that my peer dependencies is bundled, this is probably why there is now two React in my application. 如果我查看我的UMD模块,可以看到我的对等依赖项已捆绑在一起,这可能就是为什么我的应用程序中现在有两个React的原因。
I would like to know how I can prevent webpack from bundling React react in my module 我想知道如何防止webpack捆绑模块中的React react
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.