Skip to content

Instantly share code, notes, and snippets.

@tommmyy
Created August 8, 2019 10:15
Show Gist options
  • Save tommmyy/1377bb2d4b45f1a28af389fe518fd6ee to your computer and use it in GitHub Desktop.
Save tommmyy/1377bb2d4b45f1a28af389fe518fd6ee to your computer and use it in GitHub Desktop.
// One must love Dan:
// https://github.com/reduxjs/react-redux/issues/1252#issuecomment-488160930
// bindActionCreators are not good for your codebase!?
const useInfo = journey => {
const dispatch = useDispatch();
return {
goToStep: useCallback((...args) => dispatch(goToStep(...args)), [dispatch]),
goToNextStep: useCallback((...args) => dispatch(goToNextStep(...args)), [dispatch]),
goToPreviousStep: useCallback((...args) => dispatch(goToPreviousStep(...args)), [dispatch]),
submitVisibleForm: useCallback((...args) => dispatch(submitVisibleForm(...args)), [dispatch]),
submitJourney: useCallback((...args) => dispatch(submitJourney(...args)), [dispatch]),
setNumberOfSteps: useCallback((...args) => dispatch(setNumberOfSteps(...args)), [dispatch]),
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment