Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save takahirohonda/3b1c85ce076854c1ff36a456b5fee36f to your computer and use it in GitHub Desktop.
Save takahirohonda/3b1c85ce076854c1ff36a456b5fee36f to your computer and use it in GitHub Desktop.
calling-async-function-in-action-with-redux-thunk-3
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