Created
October 24, 2018 05:30
-
-
Save zanonnicola/11663177a5c151945c8bc3059d0daecf to your computer and use it in GitHub Desktop.
Handles URL changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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