Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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