October 2019
Intermediate to advanced
426 pages
11h 49m
English
We are now going to simulate the props of a component changing. Imagine the initial value for our Hook is a prop and it is initially 0, which then changes to 123 later on. If we reset our counter now, it should reset to 123 and not 0. However, to do so, we need to force the re-rendering of our test component after changing the value.
Let's now test resetting and forcing the component to re-render:
test('should reset to initial value', () => { let initial = 0
const { result, rerender } = renderHook(() => useCounter(initial)) ...Read now
Unlock full access