+ 2
What is the custom hook in react?
2 Answers
+ 3
Custom hook is quite similar to functional component, the difference are
1. custom hook name the function with use*, eg. useCustomDialog
2. custom hook function can carry input parameters eg. input text for the state/component
3. The function instead of return jsx code like functional component does, custom hooks returns object of state, private function or component.
So the main task of custom hook is to allow react code to build state, and component beforehand for its react components.
Sepideh Masoomi Study the below example, you would understand how custom hook works and helps build a cleaner react code.
https://code.sololearn.com/W2ZCTp4VKSaQ/?ref=app