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
| Option | Description | Type |
|---|---|---|
| state | the value of the Input | string |
| setState | same as React.setState | - |
| currentRef | the current value of Input | string |
| reset | reset the value of Input | () => void |
| bindings | auto-binding objects conforming to the Input props | - |
Contributors