react-hook-form: dependent fields, watch and performance benefit

Viewed 479

I have a form with 3 select fields, and each of their options are dependent on the preceding field's value. In this case, I need to watch the fields for the options to change accordingly (right?), and I'm wondering if there's any performance benefit of using react-hook-forms over the proverbial plain useState form. If not, are there any nice alternatives to keep the performance gain?

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

const Example = () => {
  const {watch, <anything else necessary...>} = useForm()
  const field1val = watch('field1')
  const field2val = watch('field2')

  const field1Options = ['fixed', 'options']
  const field2Options = someLogic(field1val)
  const field3Options = someOtherLogic(field2val)


  return (
    // render fields using <Controller /> or {...register} or whatever
  )
}
0 Answers
Related