谁能提供有关Redux-Logger过滤操作的提示?我正在尝试过滤@@redux-form/BLUR来自Redux Form的内容。
根据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
});
Run Code Online (Sandbox Code Playgroud)
基于上面引用的方法,我希望提供一条语句,该语句的格式类似,并返回false。我正在记录成功通过折叠选项的记录,因此我不会怀疑我在applyMiddlewear()中做错了什么。
predicate:(getState, action) => action.type !== @@redux-form/FOCUS || @@redux-form/BLUR || @@redux-form/FOCUS
Run Code Online (Sandbox Code Playgroud)
来自Redux-Logger的创建者:
predicate:(getState, action) => !action.type.includes('@@redux-form')
Run Code Online (Sandbox Code Playgroud)
完整示例:
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)
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
902 次 |
| 最近记录: |