yarn react-hook-form 7.55.0-next.0
🎄 Version7.55.0-next.0

2 days ago

⚡️ createFormControl

  • Allow us to start subscribing outside of the react component
const { formControl, control } = createFormControl(props)

function App() {
  const { register } = useForm({
    formControl,
  })

  return <form />
}

function Test() {
  useFormState({
    control // no longer need context api
  })
}

⚡️ subscribe

  • subscribe form state update without re-render
  • subscribe outside of the react component
const { formControl } = createFormControl(props)

control.subscribe({
  formState: { isDirty: true },
  callback: (formState) => {
    if (formState.isDirty) {
      // do something here
    }
  }
})

function App() {
  const { register } = useForm({
    formControl,
  })

  return <form />
}

Don't miss a new react-hook-form release

NewReleases is sending notifications on new releases.