DEV Community

Discussion on: Writing (clean) React code

Collapse
 
alexeychikk profile image
Alex Zinkevych

Creating objects and passing them as props directly in the render function is a bad practice.
For example, this

<Circle
 center={{x,y}}
 radius={radius}
/> 

will rerender <Circle> component on each render.

Collapse
 
jithinks profile image
Jithin KS • Edited

OK, it should be

// Circle renders if center or radius changes
<Circle
  center={center}
  radius={radius}
/>

Thanks for pointing out