resir014 / react-redux-typescript-example

Demonstrating the common patterns when using React, Redux v4, and TypeScript.
https://resir014.xyz/posts/2018/07/06/redux-4-plus-typescript/
586 stars 150 forks source link

define mapDispatchToProps as object form #7

Closed woodsmur closed 5 years ago

woodsmur commented 5 years ago

As it is recommended by redux doc always using the “object shorthand” form, for mapDispatchToProps in every page component, maybe one can change:

from

const mapDispatchToProps = (dispatch: Dispatch) => ({
  fetchRequest: () => dispatch(fetchRequest())
})

to

const mapDispatchToProps = {
  fetchRequest
}

for better readability.

resir014 commented 5 years ago

You're right. I've been using the latter at work and I agree that it's more readable and easier to type.

I'll look into it tonight.

AndrewCraswell commented 5 years ago

I just did this a few hours ago while playing with the repo. I submitted PR #9 in case it makes things easier for you.

resir014 commented 5 years ago

Awesome, thanks!