Skip to content

Instantly share code, notes, and snippets.

@irae
Created March 14, 2017 18:20
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 irae/2b477ac733d43629442c9c4982727400 to your computer and use it in GitHub Desktop.
Save irae/2b477ac733d43629442c9c4982727400 to your computer and use it in GitHub Desktop.
I love how mapDispatchToProps avoids a bound method on render
const {saveProfile, deleteProfile} = require('../actions/saved-profiles');
function mapDispatchToProps(dispatch, ownProps) {
const {profile, savedId} = ownProps;
return {
saveProfile: () => {
dispatch(saveProfile(profile));
},
deleteProfile: () => {
dispatch(deleteProfile(savedId));
},
};
}
@Montana
Copy link

Montana commented Jan 19, 2020

Pretty nifty, thanks! Just what I was looking for.

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