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

Use more ES6 syntaxes in the shopping cart example #1947

Merged
merged 6 commits into from
Sep 18, 2016
Merged

Use more ES6 syntaxes in the shopping cart example #1947

merged 6 commits into from
Sep 18, 2016

Conversation

ChrisJamesC
Copy link
Contributor

Convert the shopping cart example files to using fat arrows, spread operators and stateless components.

References #1800

return (dispatch, getState) => {
const cart = getState().cart
export const checkout = (products) => (dispatch, getState) => {
const cart = getState().cart
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're really going this far, you might as well do const {cart} = getState().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I agree, it was a total overkill before ;)

@ellbee
Copy link
Contributor

ellbee commented Sep 18, 2016

Thanks!

@ellbee ellbee merged commit d15d8e1 into reduxjs:master Sep 18, 2016
</div>
)
}
return <div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly dislike this style. Can we please do a pass in a separate PR that ensures returned multilne JSX is always wrapped in parens? As in:

return (
  <div>
    ...
  </div>
)

and

const Stuff = () => (
  <div>
    ...
  </div>
);

export function getVisibleProducts(state) {
return state.visibleIds.map(id => getProduct(state, id))
}
export const getVisibleProducts = state => state.visibleIds.map(id =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the arrow body is multiline please always start the body on the next line.
Please make it like:

export const getVisibleProducts = state =>
  ...

or

export const getVisibleProducts = state => (
  ...
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the styling advices, I'll do a pass on all of my PRs to conform with the comments you made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants