October 2019
Intermediate to advanced
426 pages
11h 49m
English
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.
Read now
Unlock full access