How do we create a custom Hook?
Here is to creating a custom Hooks step-by-step.
* Create a function : Start by defining a regular JavaScript function. It can have any name, but it's a convention to prefix it with "use" to indicate that it's a hook.
* Write the logic : Inside wer custom hook function, write the logic we want to encapsulate and reuse. we can use existing hooks like useState , useEffect , or other custom hooks if needed.
* Return values : Ensure wer custom hook returns whatever values or functions we want to expose to components that use it.
* Use the hook : we can now use wer custom hook in any functional component by calling it. React will recognize it as a hook because it starts with "use".