Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function WhySoManyProps(props) {
const user = extractUser(props);
const fudge = calculateFudge();
const bits = computeBits();
// This is soooooo redundant.
return <SomeComponent user={user} fudge={fudge} bits={bits} />;
}
function Shorthand(props) {
const user = extractUser(props);
const fudge = calculateFudge();
const bits = computeBits();
// spread all the new props which have the exact same name as the props
// for the child component using ES6 syntax.
return <SomeComponent {...{ user, fudge, bits }} />;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.