我从 redux 工具包创建了一个Slice
usingcreateSlice
并导出了我的操作,例如:
export const { myAction } = slice.actions;
我正在尝试创建一个中间件来捕捉一些动作类型:
import myAction from './reducers/mySlice'
const MyMiddleware = store => next => action => {
if (action.type === myAction.type) { //this doesn't work, myAction is a function
doSomething(action.payload);
}
return next(action);
};
我想知道是否可以从我创建的切片中将动作类型作为常量获取?