How to do it…

Setting up redux-logger requires first creating a logger with the createLogger() function, which lets you select many options to customize the logged output, and then include the generated logger as middleware for Redux

Out of the many available options, these are the most interesting:

  • colors : If you wish to change how the output looks.

  • diff: : A Boolean flag to decide if you want to display the difference between the old state and the new state; there's also a diffPredicate(getState, action) function that you can use to decide whether to display the differences.

  • duration : A Boolean flag to print how long it took to process an action; this would be interesting mainly in async actions

  • predicate(getState, action) : Can inspect the action and the current state, and return true or false to define whether the action should be logged or not; this is quite useful to restrict logging to, say, just a few action types.

  •  titleFormatter(), stateTransformer(), actionTransformer(), and several other formatter functions.

For the complete set of options, check out https://github.com/evgenyrodionov/redux-logger.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.35.255