React Component Principles and Best Practices for Better Software Architecture
1–9 of 9 posts
Re: React Component Principles and Best Practices for Better Software Architecture
#2Function Components vs. Class Components
Name of Components
Helper Functions
Repetitive Markup
Component’s Size and Length
Props
Ternary Operators
Lists Mapping
Hooks vs. HOCs and Render Props
Custom Hooks
Render Functions
Error Boundaries
Suspense
Re: React Component Principles and Best Practices for Better Software Architecture
#3Re: React Component Principles and Best Practices for Better Software Architecture
#4All of them seem to use blanket statements that lack any evidence as to why the claim being made is true. We are just expected to trust the author, when the author isn't even an expert in the topic they are discussing.
Re: React Component Principles and Best Practices for Better Software Architecture
#5In this article, we will go through: Function Components vs. Class Components Name of Components Helper Functions Repetitive Markup Component’s Size and Length Props Ternary Operators Lists Mapping Hooks vs. HOCs and Render Props Custom Hooks Render Functions Error Boundaries Suspense
If the list is large or dynamically tendered, then sure mapping over a list makes more sense.Also, passing in props as object isn't always sensible. Sometimes just spreading them out as individual props makes more sense if they're consumed together (ie to an Address one I'd prefer to use individual props instead of ).
There's nothing too wrong with components that have many props (I guess same thing that applies to functions with long argument lists applies here too, which is they can be annot to call, but use common sense).
The re-rendering thing shouldn't be a problem. You want thing to re rende if props change (assuming there's not an accidental referential instability causing spurious re-rendering)
There's also less potential performers gotchas with objects vs primitives due to how props get reconciled between rerenders), but this depends a lot on how the objects are created too.
As a rule of thumb, people should prefer primitives, not rich objects that get passed as a single props. The caveat here is that there's exceptions
The other stuff is sensible
Edit: wordsmithing
Re: React Component Principles and Best Practices for Better Software Architecture
#6I think I'm growing tired of reading articles and books that disguise opinions as "Best Practice." I find most of these types of articles and guides lacking in substance. All of them seem to use blanket statements that lack any evidence as to why the claim being made is true. We are just expected to trust the author, when the author isn't even an expert in the topic they are discussing.
Although, even though I disagree with some things on that list. They're most certainly not considered good practices, but they're also not the end of the world, really. The "burns" they'd acquire when applying some of the these tips would lead to great learning opportunities too (without being major setbacks).
Overall, a very decent article for someone starting off with React!
Re: React Component Principles and Best Practices for Better Software Architecture
#7I think I'm growing tired of reading articles and books that disguise opinions as "Best Practice." I find most of these types of articles and guides lacking in substance. All of them seem to use blanket statements that lack any evidence as to why the claim being made is true. We are just expected to trust the author, when the author isn't even an expert in the topic they are discussing.
As an industry we should spend our time pursuing other areas that are more objective.
I have nothing against the article, or the author, but especially with linked in expert opinions there is a lot of noise.
Re: React Component Principles and Best Practices for Better Software Architecture
#8Re: React Component Principles and Best Practices for Better Software Architecture
#9I think I'm growing tired of reading articles and books that disguise opinions as "Best Practice." I find most of these types of articles and guides lacking in substance. All of them seem to use blanket statements that lack any evidence as to why the claim being made is true. We are just expected to trust the author, when the author isn't even an expert in the topic they are discussing.
> Take everything as an opinion. Software can be built in multiple ways.