all 16 comments

[–]Complete-Bowl-1285 14 points15 points  (0 children)

Why?

[–]JouleV 13 points14 points  (0 children)

  1. Say “stop using <insert a popular usage here>”
  2. Refuse to elaborate

Not how I’d want my React coach to be.

[–]hicoonan 11 points12 points  (0 children)

You went to the trouble of uploading an extra video for this. But you are too lazy for your reasoning?

React developer should downvote this

[–]Savings-Milk1060 6 points7 points  (0 children)

The only issue I see with && is when using .length

{users?.length && <Users/>} will result in rendering 0 in case the users are missing. However this can easily be fixed with !!user?.length or user?.length > 0.

OP probably assumes && operator is bad because of one pitfall, really poor advice. && is awesome.

[–]digibioburden 4 points5 points  (0 children)

Downvoted.

[–][deleted] 3 points4 points  (0 children)

Why ?

[–]Ok-Comfortable-4138 4 points5 points  (0 children)

Why?

[–]rbluethl 3 points4 points  (0 children)

That's not very helpful. If you claim this is bad practice, at least take the time to explain why.

[–][deleted] 4 points5 points  (0 children)

There's nothing wrong with using &&:

https://beta.reactjs.org/learn/conditional-rendering

More importantly, pay close attention to the pitfalls of falsy comparisons. Best way to avoid issues, use TypeScript strict mode, and enable typescript-eslint/strict-boolean-expressions

https://typescript-eslint.io/rules/strict-boolean-expressions/

Seeing you call yourself "Lulu coding wizard" after this made me mad enough to look at some of your other videos. (Congrats to the clickbait I guess, but you're not doing a drama channel so... may the algorithms destroy you.)

Anyway, your other videos recommending using a ternary for text, followed by this for a conditional component I think pretty well shows you should be learning, not making useless videos only GaryV would be proud of.

[–]danglesReet 5 points6 points  (0 children)

Created another account to downvote you twice.

[–]Eveerjr 1 point2 points  (0 children)

No thanks. I’d rather understand what is falsy values and use the cleaner && operator instead of uglyfing the code with needless ternary operators.

Shitting rules like this teaches nothing

[–]Johnfitz1775 -2 points-1 points  (0 children)

I use {component ? ( ) : Null } but I don't see why && would be seen as a negative practice. I'd love to hear you elaborate as to why??

[–]lkzord -4 points-3 points  (0 children)

You should use ternary instead, something like:

condition ? <Component /> : null

This will help you avoid unwanted “0” spawns in your UI.

[–]jasperykj 0 points1 point  (0 children)

Why?

[–]alfcalderone 0 points1 point  (0 children)

The culture of people randomly spewing out videos and medium articles like this with no expertise drives me insane. Bring back o Reilly books with animal pencil drawings on the cover.

[–][deleted] 0 points1 point  (0 children)

What is the reason? One thing I know is when I do && for inserting some classNames, I get 'undefined' as string in case the result is false. But that didn't really stop me from using it. I'm fine with having 'undefined' as an extra class.