Skip to content

v3.2.1

Compare
Choose a tag to compare
@iusehooks iusehooks released this 08 Jan 14:37
b6494b3

Improvement:

  • Fix initial value undefined issue when passed as prop for useField - Input - Select - Collection - TextArea

Example:

const CustomField = ({ name }) => {
  const { value } = useField({ type: "text", name, value: "5" });

  // Now, value it is defined since the first render => value = "5"
  // does not need to wait for the <Form /> to be READY

  return (
    <pre>
      <code data-testid="output">{JSON.stringify(value)}</code>
    </pre>
  );
};

function App() {
  return (
    <Form>
      <Input type="text" name="user" value="BeBo" />
      <CustomField name="other"  />
    </Form>
  );
}