Skip to content

v3.3.0

Compare
Choose a tag to compare
@iusehooks iusehooks released this 13 Jan 15:01
4bb7cf8

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>
  );
}