有人可以提供有关Redux-Logger过滤操作的提示吗?我试图过滤来自Redux表单的@@redux-form/BLUR
等。
基于此处的Redux Logger配方https://github.com/evgenyrodionov/redux-logger#log-everything-except-actions-with-certain-type
Log everything except actions with certain type
createLogger({
predicate: (getState, action) => action.type !== AUTH_REMOVE_TOKEN
});
基于上面引用的配方,我希望提供一个声明,表达式格式相似,并返回false。我正在成功通过折叠选项,因此我不会怀疑我在applyMiddlewear()中做错了什么。
predicate:(getState, action) => action.type !== @@redux-form/FOCUS || @@redux-form/BLUR || @@redux-form/FOCUS
答案 0 :(得分:4)
来自Redux-Logger的创建者:
predicate:(getState, action) => !action.type.includes('@@redux-form')
完整示例:
import { applyMiddleware, createStore } from 'redux';
import { createLogger } from 'redux-logger';
const logger = createLogger({
predicate: (getState, action) => !action.type.includes('@@redux-form'),
//...other options
});
const store = createStore(
reducer,
applyMiddleware(logger)
);