-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Use if statement instead of ternary #371
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
Conversation
<li key={item.id}> | ||
{item.name} | ||
</li> | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
closing parens without a beginning :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typed it on iPhone so maybe I missed something but this paren should correspond to opening items.map(
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wait nevermind haha, you are right
Thanks @gaearon! I just merged and will update the surrounding text accordingly, but I do have one question: Why update |
People reading this might not have good knowledge of ES6 and might assume React forces them to use "const" or something. |
In general I've seen people being opinionated about this (both sides) so I think going with a more "relaxed" style is more beginner friendly. |
Got it. Thanks for the explanation! |
* Use if statement instead of ternary * Make it a little more compact
I think this is more consistent with how people use React in practice.
React is JS, and it is expected that you use ternaries in the same case as you would use them in JS: only if they help readability. In this case they seem to obscure it.
You still get to say that React is verbose after this change ;-)