我正在运行一个简单的Redux reducer和store,但由于某种原因,默认情况下会调用reducer.这是正常的吗?
const apiWrapper = (state = {}, action) => {
switch(action.type) {
case "HELLO":
console.log("hello");
return state;
break;
default:
console.log("default");
}
}
const { createStore } = Redux;
const store = createStore(apiWrapper);
store.dispatch({ type: "HELLO" });
Run Code Online (Sandbox Code Playgroud)
上面的代码段输出:
"default"
"hello"
Run Code Online (Sandbox Code Playgroud)
我只是希望它能够记录hello,为什么default呢?这是一个JSBin.