Building simple software
We generally think that building complex software is hard. But the hardest thing is building complex software i...
For further actions, you may consider blocking this person and/or reporting abuse
Creating objects and passing them as props directly in the render function is a bad practice.
For example, this
will rerender
<Circle>
component on each render.OK, it should be
Thanks for pointing out
Wrapping props in an object is risky business. You have to understand well how that particular prop travels down the components and where it is created and how often updated. Otherwise you'll make your app do unnecessary updates and re-renders which may impact the performance significantly.
Yeah, I think that is true. I'm not saying that you mindlessly combine every props into an object. Props that are really related to each other can be combined into an individual unit.
I can give you an example. Suppose that there is a Shapes component that renders a line and a circle.
I'm just saying that the above is better than the component below :
Simple post, but gold. I liked it.
A really good compilation of all the learnings we have acquired while working with React. Very useful!
All of these are 🔥! Thanks for the article!
If the prop is the same name as the variable, please, do this:
Hi,
What benefits will give us by wrapping data array inside the object literal?
Great read for newbies like me, thank you! 🙏🏻
this is great! very clear and to the point - will be sending links to the dev team :)
Another big gain in the point 4 is avoiding new memory allocation for the functions each render.
Point number 4 in Case 2 will create infinite loop of API calls. You should consider adding an empty array as the dependency of useEffect.
Corrected
Great read !! with good examples.