react-hook-form

๐Ÿ“‹ React Hooks for form state management and validation (Web + React Native)

MIT License

Downloads
25.6M
Stars
39.4K
Committers
318

Bot releases are hidden (Show)

react-hook-form - Version 7.20.1

Published by bluebill1049 almost 3 years ago

๐Ÿฅƒ revert #7016 and add type test coverage (#7082)
๐Ÿซ€ close #7079 flush update at the field array level before app/form-level (#7080)

react-hook-form - Version 7.20.0

Published by bluebill1049 almost 3 years ago

โœจ feature: useWatch/useFormState exact prop (#6983)

useWatch({
  name: 'test.test',
  exact: true,
});

useFormState({
  name: 'test.test',
  exact: true,
});

๐ŸŽณ close #7032 with stale onBlur value (#7078)
๐Ÿ“ฆ upgrade to ts 4.5.2 (#6944)
๐Ÿ‘‚ remove early subscription (#7056)
๐Ÿ“ฆ chore: Modify package.json to include es6 imports (#7034)
๐Ÿ—ƒ๏ธ fix(package.json): add node requirement version (#7039)

thanks to @barrymay @neighborhood999 and @karanaditya993

react-hook-form - Version 7.19.5

Published by bluebill1049 almost 3 years ago

๐Ÿž fix #7031 fast refresh (#7035)

react-hook-form - Version 7.19.4

Published by bluebill1049 almost 3 years ago

๐Ÿ’… close #7023 issue with async useFieldArray actions (#7029)
๐Ÿ‘๏ธ chore(useWatch): making the name a read-only array (#7016)
โŒจ๏ธ adds types for no supplied props argument (#7017)
๐Ÿคฆ๐Ÿปโ€โ™‚๏ธ close #7013 avoid shallow clone for the custom object (#7014)

thanks to @dborysov @sfrieson

react-hook-form - Version 7.19.3

Published by bluebill1049 almost 3 years ago

๐Ÿž fix #7011 reset API with shouldUnregister: true for controlled components (#7012)

react-hook-form - Version 7.19.2

Published by bluebill1049 almost 3 years ago

๐Ÿž fix #7009 fix fast refresh with controller (#7010)
๐Ÿ‘๐Ÿป close #7001 shouldUnregister: true with useController unmount defaultValue (#7008)
๐Ÿง  close #6994 issue with mutate original state with shouldUnreigster: true (#6998)

react-hook-form - Version 7.19.1

Published by bluebill1049 almost 3 years ago

๐Ÿž fix #6984 disabled input with register value (#6985)
๐Ÿคฒ close #6987 avoid shallow clone for object field (#6988)

react-hook-form - Version 7.19.0

Published by bluebill1049 almost 3 years ago

โœจ feature: new resetField API (#6891)

const { resetField } = useForm();

resetField('test')

resetField('test', {
  keepError: true,
  keepDirty: true,
  keepTouched: true,
  defaultValue: 'test1',
})

โฑ close #6966 improve trigger by avoiding additional validation invocation (#6967)

thanks to @barrymay and @kotarella1110

react-hook-form - Version 7.18.1

Published by bluebill1049 almost 3 years ago

๐Ÿ˜” fix 6933 by revert FieldPathWithValue type #6753 (#6934)
๐Ÿงข close #6928 prevent schema error before user's action (#6929)

thanks to @mnigh @kotarella1110 @barrymay

react-hook-form - Version 7.19.0-next.0

Published by bluebill1049 almost 3 years ago

โœจ new resetField API

const { resetField } = useForm();

resetField('test')

resetField('test', {
  keepError: true,
  keepDirty: true,
  keepTouched: true,
  defaultValue: 'test1',
})

๐Ÿงข close #6928 prevent schema error before user's action (#6929)
๐Ÿงนremove createSubscription and createSubscriber to reduce size (#6880)
โœŒ๐Ÿป improve react strict mode support with subscription
โœŒ๐Ÿป improve useController by integrating with useWatch
โœŒ๐Ÿป package size-reduction (close to 1%)
โœŒ๐Ÿป internally removed skipEarlySubscription

react-hook-form - Version 7.18.0

Published by bluebill1049 almost 3 years ago

๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘ฆ schema error parent level look up (#6869)

const validationSchema = object().shape({
  questions: array()
    .min(1, "Array cannot be empty")
    .of(
      object().shape({
        text: string().required("Some text is required")
      })
    )
});

function App() {
  const {
    control,
    formState: { errors },
    register
  } = useForm({
    mode: "onChange",
    resolver: yupResolver(validationSchema),
    defaultValues: { questions: [ { text: 'test' } ] }
  });
  const { fields, remove } = useFieldArray({
    control,
    name: "questions",
  });
  console.log(errors);
  return (
    <form>
      {fields.map((question, questionIndex) => (
        <div key={question.key}>
          <input {...register(`questions[${questionIndex}].text`)} />

          <button type="button"
            onClick={() => {
              remove(questionIndex);
            }}
          >
            Remove
          </button>
        </div>
      ))}
    </form>
  );
}

Codesandbox LInk: works with min length parent error object look up

๐Ÿ˜ž fix #6896 validation isValid mixed with schema result (#6901)
๐Ÿจ close #6899 trigger isolate render for targeted input name (#6900)
๐Ÿ‘‚ close #6889 disable early subscription with useController (#6890)
๐Ÿž fix #6792 reset with keepDefaultValues (#6886)
โ„ change the subject from class to function base to improve readability and reduce the size (#6843)
๐Ÿ‘‚๐Ÿป make sure subscriptions get unsubscribed after unmount (#6873)
๐Ÿงป prevent error lookup with fields (#6871)

Revert "Revert "โœจ Add support for generic components using `FieldPatโ€ฆ (#6753)

type ExpectedType = { test: string };

const Generic = <FormValues extends FieldValues>({
  name,
  control,
}: {
  name: FieldPathWithValue<FormValues, ExpectedType>;
  control: Control<FormValues>;
}) => {
  const {
    field: { value, ...fieldProps },
  } = useController<FormValues, ExpectedType>({
    name,
    control,
    defaultValue: { test: 'value' },
  });

  return <input type="text" value={value.test} {...fieldProps} />;
};

๐Ÿ˜ข fix #6856 regression on set input file list (#6861)
โŒจ๏ธ fix #6852 watch missing type with DeepPartial (#6854)

thanks to @kotarella1110

react-hook-form - Version 7.17.5

Published by bluebill1049 about 3 years ago

โœจ enable sharing form sections between forms in typescript (#6807)
๐Ÿž fix #6834 clearErrors not reset isValid formState to true
โš ๏ธ close #6830 warning under strict mode with Controller formState update (#6832)
๐Ÿงช include test coverage #6826 (#6827)
โœจ add TypeScript support for optional array fields (#6826)
๐Ÿ‘” allow Jest VSCode extension to run successfully on startup (#6810)

thanks to @barrymay @LinusU and @SimonSelg

react-hook-form - Version 7.17.4

Published by bluebill1049 about 3 years ago

๐Ÿ˜ฎโ€๐Ÿ’จ fix setFocus api issue #6804
โŒจ๏ธ close #6761 improve useWatch return array type (#6788)
Revert "๐Ÿงถ add support for extended generics in path type (#6762)" (#6802)
๐Ÿž fix #6792 reset keep defaultValues with useWatch return (#6794)
โšก๏ธ upgrade eslint to 8.0 and other package (#6789)

react-hook-form - Version 7.17.3

Published by bluebill1049 about 3 years ago

๐Ÿฆ— close #6777 fall back to defaultValues with shouldUnregister: true with unmount fieldArray (#6780)
๐Ÿงฏ change validation message in example code to match the rule better (#6781)
๐ŸŒณ rename document.contains to live function (#6778)
๐Ÿž fix 6764 reset with keepDefaultValues: true with isDirty and dirtyFields (#6774)
๐Ÿž fix #6765 useFieldArray trigger validation by field name (#6768)
๐Ÿงถ add support for extended generics in path type (#6762)
๐Ÿž fix #6754 focus issue with radio and checkbox (#6755)

thanks to @RolkerMan @hpohlmeyer

react-hook-form - Version 7.18.0-next.0

Published by bluebill1049 about 3 years ago

โœจ Add support for generic components using FieldPathWithValue (#6562)

type ExpectedType = { test: string };

const Generic = <FormValues extends FieldValues>({
  name,
  control,
}: {
  name: FieldPathWithValue<FormValues, ExpectedType>;
  control: Control<FormValues>;
}) => {
  const {
    field: { value, ...fieldProps },
  } = useController<FormValues, ExpectedType>({
    name,
    control,
    defaultValue: { test: 'value' },
  });

  return <input type="text" value={value.test} {...fieldProps} />;
};
react-hook-form - Version 7.17.2

Published by bluebill1049 about 3 years ago

๐Ÿž fix #6748 skip clone object when object contains function nodes (#6749)
โฎ revert interface & mapped type update (#6747)
๐Ÿž fix #6736 custom onChange getting called on blur (#6746)
๐Ÿž fix #6731 subscription issue with unmount field array (#6732)
๐Ÿ’‰ simplify controller field state error type (#6730)
๐ŸŒŸ improve reset with keepDefaultValues options (#6720)
๐Ÿ‘‚ improve useSubscribe hook (#6724)
๐Ÿ“– more TS test coverage for missing generic at useForm (#6716)

thanks to @fzkirablackwhy @kotarella1110

react-hook-form - Version 7.17.1

Published by bluebill1049 about 3 years ago

Revert "โœจ Add support for generic components using FieldPathWithValue (#6562)" (#6717)
๐Ÿ–Œ๏ธ fix Path and ArrayPath types for defined value type with interface (#6626)
๐Ÿง‰ close #6657 support equality check on date time object (#6706)

thanks to @kotarella1110 @jviall

react-hook-form - Version 7.17.0

Published by bluebill1049 about 3 years ago

โœจ Add support for generic components using FieldPathWithValue (#6562)

type ExpectedType = { test: string };

const Generic = <FormValues extends FieldValues>({
  name,
  control,
}: {
  name: FieldPathWithValue<FormValues, ExpectedType>;
  control: Control<FormValues>;
}) => {
  const {
    field: { value, ...fieldProps },
  } = useController<FormValues, ExpectedType>({
    name,
    control,
    defaultValue: { test: 'value' },
  });

  return <input type="text" value={value.test} {...fieldProps} />;
};

โš™๏ธ migrate from Select.options to Select.selectedOptions (#6678) (#6687)
๐Ÿž fix #6683 trigger regression with isValid subscription (#6686)

Thanks to @julienfouilhe and @krnlde

react-hook-form - Version 7.16.2

Published by bluebill1049 about 3 years ago

โŒจ๏ธ fix field state error type with NestedValue (#6658)
๐Ÿ‘“ fix #6655 issue with field array focus name with filter operator (#6656)
๐Ÿž fix #6651 trigger api with schema validation per field level (#6652)

Thanks to @kotarella1110 @barrymay @nicholascm @fahadsohail482

react-hook-form - Version 7.16.1

Published by bluebill1049 about 3 years ago

๐ŸŽน fix #6646 incorrect type with fieldState error (#6650)
๐ŸŽง refactor subscription logic into useSubscribe (#6614)

Thanks to @kotarella1110 @barrymay