DEV Community

Cover image for How to write redux middleware - sample code snippet
Manu Krishnan
Manu Krishnan

Posted on

1 1

How to write redux middleware - sample code snippet

Here is a sample snippet where you can add your logic to the redux middleware (this snippet will just console all your actions)

const logMiddleWare = store => next => action => {
// Replace your logic below
console.log(action.type, action);
next(action);
}

Here is how it should be included in your store

const Store = createStore(rootReducer, applyMiddleware(thunk, logMiddleWare));

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs