Skip to content

Instantly share code, notes, and snippets.

@zanonnicola
Created October 24, 2018 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zanonnicola/11663177a5c151945c8bc3059d0daecf to your computer and use it in GitHub Desktop.
Save zanonnicola/11663177a5c151945c8bc3059d0daecf to your computer and use it in GitHub Desktop.
Handles URL changes
export const routerMiddleware = history => () => next => action => {
switch (action.type) {
case PUSH:
history.push(action.payload);
break;
case REPLACE:
history.replace(action.payload);
break;
case GO:
history.go(action.payload);
break;
case GO_BACK:
history.goBack();
break;
case GO_FORWARD:
history.goForward();
break;
default:
return next(action);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment