Skip to content

Instantly share code, notes, and snippets.

@jsmanifest
Created March 13, 2020 05:53
Show Gist options
  • Save jsmanifest/5cdd9942666bc0bf8836154a5486f0ec to your computer and use it in GitHub Desktop.
Save jsmanifest/5cdd9942666bc0bf8836154a5486f0ec to your computer and use it in GitHub Desktop.
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