useInput

useInput provides automatic binding for component Input, which can reduce the amount of repetitive code and improve the development experience. Using this hooks behaves the same as if you had added React.useState manually.

General

Use hooks to capture changes.

APIs

useInput

type useInput = (initialValue: string) => {
  state: string
  setState: Dispatch<SetStateAction<string>>
  currentRef: MutableRefObject<string>
  reset: () => void
  bindings: {
    value: string
    onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
  }
}

KeyboardOptions

OptionDescriptionType
statethe value of the Inputstring
setStatesame as React.setState-
currentRefthe current value of Inputstring
resetreset the value of Input() => void
bindingsauto-binding objects conforming to the Input props-