Skip to content

Instantly share code, notes, and snippets.

@masahirompp
Last active March 8, 2017 02:26
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 masahirompp/b97792a8e10aa1b8fdcab835c2f563ba to your computer and use it in GitHub Desktop.
Save masahirompp/b97792a8e10aa1b8fdcab835c2f563ba to your computer and use it in GitHub Desktop.
export function preventDefault (func, ...args) {
return e => {
e.preventDefault()
func(...args)
}
}
export function targetValue (func, ...args) {
return e => {
func(e.target.value, ...args)
}
}
export function targetValueNumber (func, ...args) {
return e => {
func(Number(e.target.value), ...args)
}
}
// usage
<a href='#add' onClick={preventDefault(handleAdd)} >add item</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment