Skip to content

Instantly share code, notes, and snippets.

@mojaray2k
Created May 2, 2020 13:52
Show Gist options
  • Save mojaray2k/3971491767579b822208004c54dacafc to your computer and use it in GitHub Desktop.
Save mojaray2k/3971491767579b822208004c54dacafc to your computer and use it in GitHub Desktop.
Custom Thunk

A Thunk filters actions to either return a function or an object

  const thunk = (store) => (next) => (action) => {
    if (typeof action === "function") {
      return action(store.dispatch);
    }

    return next(action);
  };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment