Created
October 13, 2016 20:34
-
-
Save emilong/263aaed767b8e0e5ee6496948e138d47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
We can make it even more cleaner.