Last active
March 8, 2017 02:26
-
-
Save masahirompp/b97792a8e10aa1b8fdcab835c2f563ba 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
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