Is there a performance difference, if any, between writing
const color = props.color;
vs
const { color } = props;
Also, do we gain or lose any performance if we destructure in the parameters signature? See example3
I assume example3 in this situation would be the best way to write the function?
Example functional react components:
const example1 = (props) => {
const color = props.color;
// I know I could also just write style={{ color: props.color }}
// but for arguments sake lets say I want to write it like this.
return <h1 style={{ color }}>Hello</h1>;
};
const example2 = (props) => {
const { color } = props;
return <h1 style={{ color }}>Hello</h1>;
};
const example3 = ({ color }) => {
return <h1 style={{ color }}>Hello</h1>;
};