react-hook-form v4.0.0 Release Notes

Release Date: 2019-12-24 // over 5 years ago
  • 🍱 🥂 New feature

    • control: this will be the prop pass to RHFInput

    we probably can skip this hack too: #635

    <RHF control={control} name="test" />
    

    react-hook-form/react-hook-form-input#45


    • 🚚 move RHFInput into the main repo and rename it to Controller

    https://github.com/react-hook-form/react-hook-form-input

    <Controller control={control} name="test" />
    

    🍱 🔨 Breaking and improved changes

    • ✨improve module exports :

    (we will export all types as well)

    import { useForm } from 'react-hook-form';
    

    🍱 🚨import useForm from 'react-hook-form'; will no longer work


    • 🍱 ✨nested errors object and better typescript support

      type form = { yourDetail: { firstName: string, } }

      errors?.yourDetail?.firstName

    🍱 🚨no more flat errors :-) better TS support


    • 🍱 ✨triggerValidation argument change from Object, Object[] to String, String[]

      triggerValidation('firstName'); triggerValidation(['firstName', 'lastName']);

    🍱 🚨triggerValidation({ name: 'test', value: 'test' }); no longer work


    • 🍱 ✨watch support { nest: boolean }

      watch(); // { 'test.firstName': 'bill' } watch({ nest: true }); // { test: { firstName: 'bill' } }


    • 🍱 ✨improve custom register

      register('test', { required: true });

    🍱 🚨register({ name: 'test'}) => register('test')


    • 🍱 ✨setError support nested object

      setError('yourDetail.firstName', 'test'); errors.yourDetails.firstName;

    🍱 🚨setError('yourDetail.firstName') no longer output flat errors object


    handleSubmit no longer rerun array inputs contains undefined or null


    🍱 ✂️ API removed:

    • validationSchemaOption: hardly anyone want to use validation with abort early, or change the config.

    Thanks to @JeromeDeLeon @kotarella1110 @umidbekkarimov @bopfer