Great article! I often see examples, where the submit function of a form is wrapped in a useCallback, but I dont see the reason why someone would do that, any idea?
Hello there! The only reason I can think of is that whoever is implementing the code, does not want their handleFormSubmit() function to be created every time the component re-renders. I found this article where they use the useCallback() hook in a handleFormSubmit() to stop tree invalidation issues. However, I haven't encountered issues when creating a form without using useCallback in the past.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great article! I often see examples, where the submit function of a form is wrapped in a useCallback, but I dont see the reason why someone would do that, any idea?
Hello there! The only reason I can think of is that whoever is implementing the code, does not want their
handleFormSubmit()
function to be created every time the component re-renders. I found this article where they use the useCallback() hook in a handleFormSubmit() to stop tree invalidation issues. However, I haven't encountered issues when creating a form without using useCallback in the past.