Skip to content

Instantly share code, notes, and snippets.

@hacker0limbo
Created August 17, 2019 19:29
Show Gist options
  • Save hacker0limbo/57a877a2110d1526d3f332cbaa24440a to your computer and use it in GitHub Desktop.
Save hacker0limbo/57a877a2110d1526d3f332cbaa24440a to your computer and use it in GitHub Desktop.
custom hooks from Dan Abramov's speech
const useFormInput = initialValue => {
const [value, setValue] = useState(initialValue)
const handleChange = e => {
setValue(e.target.value)
}
return {
value,
onChange: handleChange
}
}
const FormInput = props => {
const name = useFormInput('')
return (
<input {...name} />
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment