Created
March 13, 2020 05:53
-
-
Save jsmanifest/5cdd9942666bc0bf8836154a5486f0ec 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
import React from 'react' | |
import callAll from '../utils/callAll' | |
function MyButton({ children, onClick: onClickProp, ...rest }) { | |
function onClick(e) { | |
window.alert(e.currentTarget.name) | |
} | |
return ( | |
<button onClick={callAll(onClick, onClickProp)} {...rest}> | |
{children} | |
</button> | |
) | |
} | |
function App() { | |
function onClick(e) { | |
console.log('Here is the event object', e) | |
} | |
return ( | |
<div> | |
<MyButton name="alerter" onClick={onClick}> | |
Alert | |
</MyButton> | |
</div> | |
) | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment