Closed decovicdev closed 1 year ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
react-hook-form-website | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Sep 19, 2023 4:19pm |
Description:
This PR adds an enhancement to the React Hook Form documentation by demonstrating how to share a ref using the
useImperativeHandle
hook. The shared ref is used to clear the input value when a user clicks on a "clear" button.Changes Made:
useImperativeHandle
to share a ref.App
) that utilizesuseForm
fromreact-hook-form
.ref
usinguseRef
to reference the input element.onSubmit
function to handle the form submission.ref
and other properties from theregister
function for the "firstName" input field.onClick
function that clears the value of the input element when the "clear" button is clicked.useImperativeHandle
to share theref
with the parent or other components.Testing Done: