Thank you so much for this! I was really struggling with calling the custom hook at a later time. I kinda hit a dead end and thought I might better off writing the entire thing inside my component, but thanks to you. Now my hook resides in a separate component, nice and neat.