在我以前的Meteor应用程序中,使用browserify和React,所有工作都在运行,直到我切换到meteor webpack.
我在我的meteor应用程序中使用react-select并且它工作得很好但是使用browserify我可以阻止多个反应来自加载,这可以防止我现在遇到的这个错误:
错误:不变违规:addComponentAsRefTo(...):只有ReactOwner可以有refs.您可能正在向未在组件
__CODE__
方法中创建的组件添加引用,或者您已加载多个React副本(详细信息:https://fb.me/react-refs-must-have-owner).
我的package.json看起来像这样:
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).
在webpack中是否有配置我可以使用外部调用?不完全确定这意味着什么,但评论说使用:
...
"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"
},
...
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个React-Redux库,我正在尝试使用create-react-app来获取样板代码,但它在构建脚本中包含了与appHtml无关的内容.
有没有办法将弹出的create-react-app转换为库 - 特别是我需要不将所有js文件打包成一个,而只是通过babel传递它们并为每个React组件生成单独的文件?
说webpack的配置如下
{
entry: path.join(__dirname, 'src', 'index.js'),
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js'
},
Run Code Online (Sandbox Code Playgroud)
现在的构建webpack
是
和react-scripts构建的构建(静态包含css,js和媒体在单独的文件夹中)
问题:与react-scripts构建相比,webpack有什么特别的优势吗?(包括但不限于性能)
注意:package.json被编辑以实现此目的。