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.
Use hooks to capture changes.
type useInput = (initialValue: string) => {
state: string
setState: Dispatch<SetStateAction<string>>
currentRef: MutableRefObject<string>
reset: () => void
bindings: {
value: string
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
}
}
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 | - |
Previous
useCurrentState
Next
useKeyboard