Skip to content

Fix const xxx(x, y) {…} and similar pseudo-code#32

Merged
maxkfranz merged 1 commit intoplotly:masterfrom
pawel-schmidt:patch-1
Jul 3, 2019
Merged

Fix const xxx(x, y) {…} and similar pseudo-code#32
maxkfranz merged 1 commit intoplotly:masterfrom
pawel-schmidt:patch-1

Conversation

@pawel-schmidt
Copy link
Copy Markdown
Contributor

No description provided.

@maxkfranz maxkfranz self-requested a review June 27, 2019 00:45
@maxkfranz maxkfranz merged commit dd8cf7c into plotly:master Jul 3, 2019
@maxkfranz
Copy link
Copy Markdown
Collaborator

Because these props would often be defined in an object literal, you don't need to specify the function keyword or =>. But you're right in those cases that you shouldn't use the const keyword.

Since I don't use JSX, I was thinking more in terms of using an object literal for props. However, most people probably use JSX, so your style would be more natural for code in JSX within something like toJson={ /*...*/ }.

Thanks for the PR.

@pawel-schmidt
Copy link
Copy Markdown
Contributor Author

Hey Max,

thank you for your effort.

The thing is, the expression const toJson(object) = object; is syntactically wrong. That was the main purpose of this PR.

The second goal was to add some clearance in cy => this.cy = cy - at first look it's hard to say if it is (cy => this.cy) = cy or cy => (this.cy = cy). Currly braces also give reader information that the cy prop function doesn't expect anything to return.

PS I've just noticed that my const diff = (objectA, objectB) => objectA !== objectB; could be more verbose if you wrap objectA !== objectB in parenthesis ;-)

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.

2 participants