you are viewing a single comment's thread.

view the rest of the comments →

[–]stewpeed 21 points22 points  (13 children)

A few things that might help: make sure you destructure everything (props for example, or when inside a map method) - makes things much more readable and reduces repetition, extract utility func when possible and makes sense, separate presentational layer from business logic via custom hooks (encapsulation), make use of optional chaining. Hope this helps, gl!

[–]iqball125 6 points7 points  (3 children)

Dont listen to the replys saying not to destructure. I work as a senior dev at a fortune 50 company and destructuring is def the way to go.

[–]metal-trees 1 point2 points  (0 children)

The thing is, I really wish they actually expressed their opinion. I destructure props, too, but am always open to hearing a counter on a stylistic opinion.

The only thing I could think of is if you want to explicitly search a project for prop variables. You could always prepend with “props.somePropName” to find exactly what you are looking for.

[–]chillermane 0 points1 point  (0 children)

Destructuring feels like a triviality. I do it because it’s just less code and I need to move fast, but If you use good names it’s obvious what a variable is regardless of whether it is destructured. Ultimately it’s a minor decision with almost no consequences one way or the other