Last active
June 30, 2020 18:38
-
-
Save kyleshevlin/c921225857f26244cf7a4e5b89edb2a0 to your computer and use it in GitHub Desktop.
This file contains 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
// This component has the prop `children` | |
// In a universe of infinite possibilities, | |
// the only limit is that `children` is inside | |
// the `div`. There are no other limits. | |
function Wrap({ children }) { | |
return <div>{children}</div> | |
} | |
const BOX_SIZES = { | |
small: 100, | |
large: 250, | |
} | |
function getBoxWidth(size) { | |
const width = BOX_SIZES[size] | |
return width !== undefined ? width : BOX_SIZES.small | |
} | |
// This component has the prop `size` | |
// It is _very_ limiting. In a universe of infinite | |
// possibilities, there are only 2 options. Everything else | |
// is off limits. | |
function Box({ size = 'small' }) { | |
return <div style={{ width: getBoxWidth(size) }}>I am a box</div> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment