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.
constShapes=(props)=>{// Here we destructured the respective parameters child components want// And passing to the componentsconst{lineParams}=propsconst{circleParams}=props// Line and circle rerender only if their respective props changereturn(<><Lineparams={lineParams}/>
<Circleparams={circleParams}/>
</>
)}
constShapes=(props)=>{const{combinedParams}=props// Here we have mindlessly combined everything into one// So whenever it changes both will rerender which we do not want// Props that are combined should be taken out// at appropriate levelsreturn(<><Lineparams={combinedParams}/>
<Circleparams={combinedParams}/>
</>
)}
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 :