Skip to content

Instantly share code, notes, and snippets.

@StevenJL
Created September 14, 2018 00:04
Show Gist options
  • Save StevenJL/2bfa8873ad45beef66ff08eec79afec4 to your computer and use it in GitHub Desktop.
Save StevenJL/2bfa8873ad45beef66ff08eec79afec4 to your computer and use it in GitHub Desktop.
function createThunkMiddleware(extraArgument) {
return ({ dispatch, getState }) => next => action => {
if (typeof action === 'function') {
return action(dispatch, getState, extraArgument);
}
return next(action);
};
}
const thunk = createThunkMiddleware();
thunk.withExtraArgument = createThunkMiddleware;
export default thunk;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment