Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Instead of writing

     <ComponentName someVariable={true}>
It’s just

     <ComponentName someVariable>
Of course there might be some completely valid reason for this, but it’s baffling to me why you would want this type of shorthand, instead of just explicitly writing what you mean.

Of course in golang this could be something like:

    var someVariable  //is false

    someFunction(someVariable)
But I would (personally) not write code like this if I could avoid it. It would be:

    someVariable := false

    someFunction(someVariable)
It’s a little bit longer, but imo takes slightly less mental overhead to read.


It's a shorthand, and its similar to what HTML does.

If you don't like the optional shorthand, don't use it? I don't understand how this is something exclusive to React, or something it specifically encourages.


Yeah you might be right, and it definitely possible this is common and I’m just weird for not liking it.


It’s common, but you’re not weird. I’ve done a lot of React and front end programming, and I hate this pattern, too.



I'm with you on this one, I've seen people rewrite things like this, and to me this is just personal preferences, and it's something that the team need to agree on.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: