Stateful hook for controlled input components
npm install --save use-input-hook
import * as React from 'react'
import useInput from 'use-input-hook';
const App = () => {
const [inputValue, onInputChange] = useInput("");
const [textAreaValue, onTextAreaChange] = useInput("");
const [checkBoxValue, onCheckboxChange] = useInput(false, 'checked');
return (
<>
<div>
Input: <input type='text' value={inputValue} onChange={onInputChange} />
</div>
<div>
Textarea: <textarea value={textAreaValue} onChange={onTextAreaChange} />
</div>
<div>
Checkbox: <input type="checkbox" value={checkBoxValue} onChange={onCheckboxChange} />
</div>
</>
)
}
MIT © SiddharthMantri