Function useInput

A custom React hook for managing the state of an input element.

const { value, onChange } = useInput('initial');
<input value={value} onChange={onChange} />
  • Parameters

    • initialValue: string

      The initial value of the input element.

    Returns { onChange: (evt: ChangeEvent<HTMLInputElement>) => void; value: string }

    An object containing:

    • value: The current value of the input element.
    • onChange: A callback function to update the value when the input changes.