Skip to content

Instantly share code, notes, and snippets.

@diegocasmo
Created March 13, 2017 14:08
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 diegocasmo/24016343f380243dd9533ed4b0588ba3 to your computer and use it in GitHub Desktop.
Save diegocasmo/24016343f380243dd9533ed4b0588ba3 to your computer and use it in GitHub Desktop.
A Redux middleware to redirect a user after a TODO has been successfully deleted.
import {browserHistory} from 'react-router'
export const redirectMiddleware = createMiddleware([
{
// Redirect user to index page on successful TODO delete
action: TODO__DELETE__SUCCESS,
afterHandler: (storeAPI, action) => {
browserHistory.replace({pathname: '/'});
}
}
]);
@diegocasmo
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment