我按照教程进行操作,但是,出现控制台错误:
“错误:期望减速器是一个函数”
这是我的(相关)配置:
WEBPACK.CONFIG.JS:
...
const TARGET = process.env.npm_lifecycle_event;
process.env.BABEL_ENV = TARGET;
...
if( TARGET === "start" || !TARGET ) {
module.exports = merge( common, {
devtool : "inline-source-map",
devServer : {
contentBase : PATHS.build,
hot : true,
progress : true,
stats : "errors-only"
},
plugins : [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
"process.env.NODE_ENV" : JSON.stringify( "production" )
})
]
} );
}
索引.JS:
import React from "react";
import { render } from "react-dom";
import { Provider } from "react-redux";
import configureStore from "./modcon/ConfigureStore.js";
import MainInterface from "./component/Main.jsx";
import DevTools from "./component/devTools/DevTools.js";
export const store = configureStore();
let initialise = () => {
render(
<Provider store = { store }>
<div>
<MainInterface />
<DevTools />
</div>
</Provider>,
);
};
initialise();
CONFIGURESTORE.JS:
if (process.env.NODE_ENV === "production") {
module.exports = require("./ConfigureStore.prod");
} else {
module.exports = require("./ConfigureStore.dev");
}
CONFIGURESTORE.DEV.JS:
import { createStore, applyMiddleware, compose } from "redux";
import reducer from "./Reducers.js";
import DevTools from "../component/devTools/DevTools";
const enhancer = compose(
DevTools.instrument()
);
export default function configureStore( initialState ) {
const store = createStore( reducer, initialState, enhancer );
console.log( module.hot );
if (module.hot) {
module.hot.accept("./Reducers", () =>
store.replaceReducer(require("./Reducers")/*.default if you use Babel 6+ */));
}
return store;
}
我不清楚我做错了什么。谢谢