Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of bindActionCreators #33

Open
ZeshanA opened this issue Dec 21, 2018 · 1 comment
Open

Remove usage of bindActionCreators #33

ZeshanA opened this issue Dec 21, 2018 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@ZeshanA
Copy link
Member

ZeshanA commented Dec 21, 2018

Currently, the codebase uses bindActionCreators in conjunction with mapDispatchToProps. This may be unnecessary, see Option 4 here and this article

image

@ZeshanA ZeshanA added the question Further information is requested label Dec 21, 2018
@ZeshanA ZeshanA self-assigned this Dec 21, 2018
@ZeshanA
Copy link
Member Author

ZeshanA commented Jan 11, 2019

So this is definitely not best practice, as mentioned in the React-Redux documentation here.

We should swap all mapDispatchToProps to be defined using object shorthand, we don't need the additional control over dispatch offered by defining it as a function. Will do this manually at some point, it isn't critical.

mapDispatchToProps as a function

const mapDispatchToProps = dispatch => bindActionCreators({
    createNewRegion: createNewRegion,
    handleFormSubmit: handleFormSubmit
});

mapDispatchToProps as an object (recommended)

const mapDispatchToProps = {
    createNewRegion,
    handleFormSubmit
}

@ZeshanA ZeshanA closed this as completed Jan 11, 2019
@ZeshanA ZeshanA reopened this Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant