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

Опубликовано: 13 Март 2026
на канале: Kent C. Dodds
15,400
225

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.