A very common use case when dealing with Hooks, is to store the current value of an input field using State and Effect Hooks. We have already done this many times throughout this book.
The useInput Hook greatly simplifies this use case, by providing a single Hook that deals with the value variable of an input field. It works as follows:
import React from 'react'
import { useInput } from 'react-hookedup'
export default function App () {
const { value, onChange } = useInput('')
return <input value={value} onChange={onChange} />
}
This code will bind an onChange handler function and value to the input field. This means that whenever we enter text into the input field, the value will automatically be updated.
Additionally, there is a function that will clear the input field. This clear function is also returned...