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從「反應 - 終極版」;' –
是的,我意識到,不久後發帖! :) –
啊謝謝!與* :) –