DEV Community

Discussion on: Data fetching React Hook

Collapse
 
sebalreves profile image
sebalreves

how can i use this hook for submitting a form? it gives me an error because it's calling inside the submitHandler function. Or it's better just to write an asynchronous function for this?

Collapse
 
mbellagamba profile image
Mirco Bellagamba

This hook cannot work for mutation requests, like form submissions, because it starts the fetch request as soon as the component is mounted. If you need to handle form submissions you should write a "classic" async handler.