useForm
The useForm hook is used inside the Form component. It uses the useFetch hook and is a specialized hook for submitting form data to the provided URL endpoint.
This hook is a public hook and available for the users to use.
Code
Explanation
It accepts a single parameter, a URL endpoint provided to fetch.
It returns the following:
updateData
-> a function to update form fields for controlled form.submit
-> a function to submit the form data.submitted
-> a state value which tells if the form is submitted or not.returnValue
-> a function to return the value responded by the endpoint after submitting the form data.
Usage
Last updated