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.16.0

Published by bluebill1049 about 3 years ago

๐Ÿช„ feat: Ability to provide custom onBlur and onChange handlers (#5620)

<input
  type="text"
  {...register('test', {
    onChange: (e) => {},
    onBlur: (e) => {},
  })}
/>

๐Ÿ—บ๏ธ fix Mapped types for defined value type with interface (#6605)
๐Ÿฅ close #6590 prevent error throw by missing input with trigger API (#6591)

Thanks to @kotarella1110 @exneval @michalbundyra

react-hook-form - Version 7.15.4

Published by bluebill1049 about 3 years ago

๐Ÿ‘จโ€๐Ÿญ close #6581 by register input with setValue to improve DX for missing registered inputs (#6582)
๐Ÿ’‰ include unit test for #6581 setValue with missing input
๐Ÿž fix #6573 calling setValue from useEffect at mount does not update controller value (#6578)
โŒš๏ธ close #6548 watch, reset with shouldUnregister: true by trigger extra re-render to flush out the current form values (#6549)
๐Ÿž fix async useFieldArray actions (#6540)
๐Ÿ”– fix typos in examples and source code (#6531)
๐Ÿ’‰ replace updateValues with cloneObject (#6530)

Thanks, @frankie303

react-hook-form - Version 7.15.3

Published by bluebill1049 about 3 years ago

๐Ÿž fix #6528 async reset update isMounted when isValid is not subscribed (#6529)
๐Ÿž fix #6513 reset config keepValues update formValues (#6524)
๐Ÿž fix #6482 reset formValues with shouldUnregister: true (#6512)
๐Ÿž fix #6509 return defaultValues when components are not mounted (#6511)
๐Ÿ”จ proper fix for useController default value update (#6510)

react-hook-form - Version 7.15.2

Published by bluebill1049 about 3 years ago

๐Ÿž fix #2655 disabled input should set to undefined (#6501)
๐Ÿž improve ControllerFieldState type for Controller types (#6500)
๐Ÿž add File and FileList interface for ReactNative (#6495)

Thanks, @kotarella1110

react-hook-form - Version 7.15.1

Published by bluebill1049 about 3 years ago

๐Ÿš€ fix: add UnionLike type for FieldErrors and FieldNamesMarkedBoolean type (#6381)
๐Ÿ’ป ci: update from ubuntu-16.04 to ubuntu-latest (#6485)
๐Ÿž fix handleChange to set undefined value (#6481)
๐Ÿž fix #6473 isMount flag for useWatch value subscription (#6474)
๐Ÿž fix #6469 schema checkbox validation incorrect parent node lookup (#6471)

react-hook-form - Version 7.15.0

Published by bluebill1049 about 3 years ago

๐ŸŽ‡ [useFieldArray] new method replace() (#6304)

const { control } = useForm({
  defaultValues: {
    test: [{ value: 'lorem' }, { value: 'ipsum' }]
  }
});
const { fields, replace } = useFieldArray({ 
  control, 
  name: 'test'
});

const handleFullyReplacement = (): void => {
  // remove old and set fully new values
  replace([{ value: 'dolor' }, { value: 'sit' }, { value: 'amet' }]);
}

๐Ÿž fix #6379 toggle disabled props with register api (#6459)
๐Ÿ—บ๏ธ improve Mapped types (#6451)
๐Ÿ—๏ธ refactor: improve NestedValue type (#6449)
๐Ÿ—๏ธ feat: improve PathValue type to fully support union type (#6431)

react-hook-form - Version 7.14.3-beta.0

Published by bluebill1049 about 3 years ago

๐Ÿ”‘ fix: add UnionLike type for FieldErrors type #6381

react-hook-form - Version 7.14.2

Published by bluebill1049 about 3 years ago

๐Ÿ› fix #6403 issue with fields object with getter and setter function (#6407)
โŒจ๏ธ update watch observer types (#6404)
๐Ÿงฅ fix getter and setter consistency (#6408)

react-hook-form - Version 7.14.1

Published by bluebill1049 about 3 years ago

๐Ÿ‘พ improve change event perf (#6373)
๐Ÿž fix #6379 when disabled is not return from the DOM attribute (#6380)
๐Ÿงป code improvement and size reduction (#6372)
๐ŸŽฎ prevent controller with TypeError: e.focus is not a function (#6386)
Revert "๐ŸŽน fix #6265 objects may have error messages (#6275)" (#6391)

react-hook-form - Version 7.14.0

Published by bluebill1049 about 3 years ago

๐Ÿฅณ feature: add dependent validation - run a dependent field's validation after another field's validation runs (#6141)

const App = () => {
  const { register, getValues } = useForm();

  return (
    <form>
      <input
        {...register('firstName', {
          validate: (value) => {
            return getValues('lastName') === value;
          }
        })}
      />
      <input {...register('lastName', { deps: ['firstName'] })} /> // dependant validation
    </form>
  );
};

๐Ÿฆ† close #6319 remove shallow clone with watch return value (#6336)
๐Ÿ—๏ธ fix #6320 type issue with provider context (#6326)
๐ŸŽ›๏ธ fix #6335 useController only update field ref #6341
๐ŸŽฎ close #6328 useController set defaultValue to be part of formValues (#6329)
๐Ÿ“ญ close #6367 missing absent empty object and array input from defaultValues (#6368)

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

Published by bluebill1049 about 3 years ago

๐Ÿฅณ feature: add dependent validation - run a dependent field's validation after another field's validation runs (#6141)

const App = () => {
  const { register, getValues } = useForm();

  return (
    <form>
      <input
        {...register('firstName', {
          validate: (value) => {
            return getValues('lastName') === value;
          }
        })}
      />
      <input {...register('lastName', { deps: ['firstName'] })} /> // dependant validation
    </form>
  );
};

๐Ÿฆ† close #6319 remove shallow clone with watch return value (#6336)
๐Ÿ—๏ธ fix #6320 type issue with provider context (#6326)
๐ŸŽ›๏ธ fix #6335 useController only update field ref #6341
๐ŸŽฎ close #6328 useController set defaultValue to be part of formValues (#6329)

react-hook-form - Version 7.13.0

Published by bluebill1049 about 3 years ago

๐ŸŽ Performance enhancement at scale

React hook from is getting a general performance upgrade and enhancement. The following API will get big performance improvement at scale, which means it may not improve on small or medium-size applications, but rather large and complex applications with subscriptions.

  • useWatch
  • useFieldArray
  • watch
  • getValues

Result Env: dev build + throttle 4x CPU + Chrome + MAC M1

Version Flat (1000) Nested (1000) Deeply Nested (1000 * 2 * 2000) Flat (1000) Mount
7.13.0-next.0 18ms 20ms 200ms 470ms (no change)
7.11.1 40ms 43ms 2000ms 470ms

๐Ÿ“ฆ Package size-reduction

  • 5% package size reduction with compress and gzip

Total Size: 30.3 kB

Filename Size Change
dist/index.cjs.js 8.39 kB -445 B (5%) โœ…
dist/index.esm.js 13.4 kB -656 B (4%)
dist/index.umd.js 8.52 kB -420 B (4%)

๐Ÿ”ซ Trigger

  • Trigger will enable object name trigger and field array name trigger
useFieldArray({ name: 'test' })

trigger('name') // will trigger the whole field array to validate

๐Ÿ“‘ register

  • added a disabled prop as an option to toggle input disable attribute
  • register will be able to seek input DOM reference through the ref callback
register('test', { disabled: true }) // will set value to undeinfed and pass disabled down to the input attribute

<div {...register('test')}>
  <input name="test" /> // this input will be registered
</div>

๐Ÿ‘€ useWatch

  • added disabled prop to toggle the state subscription.
useWatch({ disabled: true }) // you toggle the subscription

โŒจ๏ธ useFormState

  • added disabled prop to toggle the state subscription.
useFormState({ disabled: true }) // you toggle the subscription

โ›ณ๏ธ setValue

  • allow set value for non-registered inputs include nested object and array field.
<input {...register('test.0.firstName')} />

setValue('test', [{ firstName: 'bill' }, {firstName: 'kotaro}, {firstName: 'joris'}]) // this will works

Resolved issues:

โฑ๏ธ close #6296 abort validation early when disable prop is detected (#6300)
๐ŸŽน fix #6265 objects may have error messages (#6275)
๐Ÿ”„ fix #6277 track async validate to trigger state update (#6284)
๐Ÿž fix #6272 only flush field array when subscription name match (#6281)
๐Ÿ’ช๐Ÿป simplify fillEmptyArray and combine focus name (#6237)
๐ŸŒต remove redundant code for useFieldArray (#6236)
๐Ÿž patch remove, update api with key id persist (#6235)
๐Ÿž close #6233 for persist field array id (#6234)
๐Ÿ„ enable detect fields unmount at useWatch level (#6226)
๐Ÿ’จ improve useFieldArray perf (#6215)
๐Ÿจ close #6193 to remove shallow merge with defaultValue with watch (#6201)
๐Ÿž fix #6186 delayError with set error after delay (#6188)
โ˜„๏ธ enhance unregister unmount inputs by combining its logic (#6185)
๐Ÿ–จ๏ธ include reset clone value for array/object/date (#6183)
๐Ÿ‘จ๐Ÿปโ€๐Ÿ”ง fix rendering order with useFieldArray (#6182)
๐ŸŽญ skip the shallow clone with useForm return (#6154)
โŒจ๏ธ fix: WatchObserver info name type (#6171)

react-hook-form - Version 7.13.0-next.5

Published by bluebill1049 about 3 years ago

๐Ÿž patch remove, update API with key id persist (#6235)

react-hook-form - Version v7.13.0-next.4

Published by bluebill1049 about 3 years ago

๐Ÿž close #6233 for persist field array id (#6234)
๐Ÿ„ enable detect fields unmount at useWatch level (#6226)

react-hook-form - Version 7.13.0-next.3

Published by bluebill1049 about 3 years ago

๐Ÿจ close #6193 to remove shallow merge with defaultValue with watch (#6201)
๐Ÿ’จ improve useFieldArray perf (#6215)

react-hook-form - Version 7.13.0-next.2

Published by bluebill1049 about 3 years ago

๐Ÿž fix #6186 delayError with set error after delay (#6188)

react-hook-form - Version 7.13.0-next.1

Published by bluebill1049 about 3 years ago

๐Ÿ–จ๏ธ include reset clone value for array/object/date (#6183)
๐Ÿ‘จ๐Ÿปโ€๐Ÿ”ง fix rendering order with useFieldArray (#6182)
๐ŸŽญ skip the shallow clone with useForm return (#6154)
โŒจ๏ธ fix: WatchObserver info name type (#6171)

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

Published by bluebill1049 about 3 years ago

This new release is going to be quite an improvement over the existing version. We will start with next (beta) version.

๐ŸŽ Performance enhancement at scale

React hook from is getting a general performance upgrade and enhancement. The following API will get big performance improvement at scale, which means it may not improve on small or medium-size applications, but rather large and complex applications with subscriptions.

  • useWatch
  • useFieldArray
  • watch
  • getValues

Result Env: dev build + throttle 4x CPU + Chrome + MAC M1

Version Flat (1000) Nested (1000) Deeply Nested (1000 * 2 * 2000) Flat (1000) Mount
7.13.0-next.0 18ms 20ms 200ms 470ms (no change)
7.11.1 40ms 43ms 2000ms 470ms

๐Ÿ“ฆ Package size-reduction

  • 5% package size reduction with compress and gzip

Total Size: 30.3 kB

Filename Size Change
dist/index.cjs.js 8.39 kB -445 B (5%) โœ…
dist/index.esm.js 13.4 kB -656 B (4%)
dist/index.umd.js 8.52 kB -420 B (4%)

๐Ÿ”ซ Trigger

  • Trigger will enable object name trigger and field array name trigger
useFieldArray({ name: 'test' })

trigger('name') // will trigger the whole field array to validate

๐Ÿ“‘ register

  • added a disabled prop as an option to toggle input disable attribute
  • register will be able to seek input DOM reference through the ref callback
register('test', { disabled: true }) // will set value to undeinfed and pass disabled down to the input attribute

<div {...register('test')}>
  <input name="test" /> // this input will be registered
</div>

๐Ÿ‘€ useWatch

  • added disabled prop to toggle the state subscription.
useWatch({ disabled: true }) // you toggle the subscription

โŒจ๏ธ useFormState

  • added disabled prop to toggle the state subscription.
useFormState({ disabled: true }) // you toggle the subscription

โ›ณ๏ธ setValue

  • allow set value for non-registered inputs include nested object and array field.
<input {...register('test.0.firstName')} />

setValue('test', [{ firstName: 'bill' }, {firstName: 'kotaro}, {firstName: 'joris'}]) // this will works
react-hook-form - Version 7.12.2

Published by bluebill1049 about 3 years ago

โœŒ๐Ÿป close #6124 move isValid state into a separate function to unblock validation
๐Ÿž fix #6105 deep equal issue with undefined node (#6107)

react-hook-form - Version 7.12.1

Published by bluebill1049 about 3 years ago

๐Ÿž fix #6090 issue with set defaultValue as string with valueAs (#6093)
๐Ÿž make sure the field is set before setting it to mounted (#6084)
๐Ÿž fix #6081 issue with delayError with formState (#6083)