Skip to content

Instantly share code, notes, and snippets.

@giuseppeg
Created January 4, 2019 17:24
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 giuseppeg/1929352c1cd49229547566c97e34ebaa to your computer and use it in GitHub Desktop.
Save giuseppeg/1929352c1cd49229547566c97e34ebaa to your computer and use it in GitHub Desktop.
function MenuButton({ children }) {
let called = false
function getButtonProps(props) {
const merged = merge({
onClick: () => {},
role: 'button',
}, props)
called = true
return merged
}
const rendered = children({ getButtonProps })
if (!called) {
throw new Error('must call getButtonProps')
}
return rendered
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment