Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kyleshevlin
Last active June 30, 2020 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleshevlin/c921225857f26244cf7a4e5b89edb2a0 to your computer and use it in GitHub Desktop.
Save kyleshevlin/c921225857f26244cf7a4e5b89edb2a0 to your computer and use it in GitHub Desktop.
// 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