Testing · Junior · Question 78 of 78
Why test a custom hook through a component (or renderHook) rather than calling it directly?
- ✓Correct answer: Hooks can only be called during React rendering
- 2Calling hooks directly is faster but less precise
- 3Hooks can't be imported in tests
Explanation
A direct call breaks the rules of hooks. renderHook renders a tiny test component around the hook.