2
我正在使用webpack和babel。我有这样一个文件:为什么不定义ReactRedux?
import React from 'react';
import ReactRedux from 'react-redux';
var Layout = React.createClass({
render(){
return (<div>Markup</div>);
}
});
function mapStateToProps(state, action) {
return state;
}
export default ReactRedux.connect(mapStateToProps)(Layout);
出于某种原因,当我运行的WebPack,编译后,它与此错误运行:Cannot read property 'connect' of undefined
。不知道为什么它会在获取ReactRedux对象时失败。我的webpack配置是这样的:
var compiler = webpack({
entry: "./dist/runner.js",
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel', // 'babel-loader' is also a legal name to reference
query: {
presets: ['es2015', 'react']
}
}
]
},
devtool: 'source-map',
output: {
filename: "public/dist/bundle.js"
}
});
,或者,'进口*为ReactRedux从“反应 - 终极版”;' –
是的,我意识到,不久后发帖! :) –
啊谢谢!与* :) –