Created
January 4, 2019 17:24
-
-
Save giuseppeg/1929352c1cd49229547566c97e34ebaa 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
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