DEV Community

[Comment from a deleted post]
Collapse
 
jsardev profile image
Jakub Sarnowski

There is no downside in that as long as you are certain what the object you're spreading into the component looks like. In this case, it's easy to start passing things that the component doesn't even need, and introduce unnecessary rerenders.

Collapse
 
grikomsn profile image
Griko Nibras

So for example, if a component only needs A and B but C is also given, and if C is changed, it wil rerender?

Collapse
 
jsardev profile image
Jakub Sarnowski

Exactly! Even if the component doesn't use that prop at all, it will still rerender.

Collapse
 
doctorzink profile image
Aleodor • Edited

That it would, yep. Also think about the contract of you component, so to say.
I think you are adding an additional, not necessary layer in the middle, the reading patterns of the code would be as following:

Component usage -> Wrapper Object definition -> Value definition

vs

Component usage -> Value definition

I am usually reluctant to bring in any indirection if it doesn't have great value to add to the code.

My 2 cents,
Ale