Improvement:
- innerRef prop can be passed to Form - Input - Select - TextArea
- setValue added to useField({ type="custom"})
Example:
const CustomField = ({ name }) => {
const { value, setValue } = useField({ type: "custom", name, value: "5" });
const onSetValue = () => setValue(prev => ++prev)
return (
<pre>
<code data-testid="output">{JSON.stringify(value)}</code>
<button type="button" onClick={onSetValue}>Set Value</button>
</pre>
);
};
function App() {
const formRef = useRef();
const inputRef = useRef();
return (
<Form innerRef={formRef} >
<Input innerRef={inputRef} type="text" name="user" value="BeBo" />
</Form>
);
}