React props: Should I pass the object or its properties? Does it make much difference?
According to the principle of least privilege, this is a correct way: <InnerComponent name={object.name} image={object.image} /> This restricts InnerComponent from accidentally modifying original object or accessing properties that aren’t intended for it. Alternatively, properties could be picked from original object and passed as props: <InnerComponent {…pick(object, ‘name’, ‘image’)} /> If there are numerous properties that … Read more