Testing · Middle · Question 23 of 75

What does renderHook return?

const { result } = renderHook(() => useCounter());
act(() => result.current.increment());
expect(result.current.count).toBe(1);

Explanation

Updates from outside React events must be wrapped in act. For hooks used by one component, testing that component is often better.

Further reading

Problem with a question

Testing · Middle · question 23

Test yourself

Take the Testing · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz