Logo Awesome React

Awesome React

How NOT to test custom React hooks (and how to test them)

Codesandbox: https://codesandbox.io/s/lp057z0vxz

It can be tempting to try and call your custom hook manually and test it that way, but you'll run into the error "Hooks can only be called inside the body of a function component." And for good reason. Let's talk about why that is and the proper way to test a custom React hook.