I was curious about if it's possible to call a custom hook as and when required.
Let's say I have a simple custom hook - useLogToConsole() which just logs 'Hello World' to the console. Now I know I can call this hook on top of my component. But I'd like to call this hook again(as many times as I want to) on a button click.
When I do the same, it works just fine but with an error message that 'React Hook "useCustomHook" cannot be called inside a callback.'
I know this isn't a good coding practice, but I was just curious. Let me know your thoughts.