就上述问题:方法2 比 方法1 更推荐的原因
// 方法1
fetchChannlList(dispatch)
// 方法2
dispatch(fetchChannlList2())
当使用方法1时,下面reducer只会触发reducer,而不会走prepare的逻辑
而当使用方法2时,入参会先进入prepare后通过return,进入reducer
setChannel1: {
reducer(state, action) {
console.log("state -- ", state)
console.log("action -- ", action)
// state.push(action.payload)
},
prepare(title, content) {
console.log("title -- ", title)
console.log("content -- ", content)
return {
payload: {
id: 1,
title,
content
}
}
}
}
未完待续