setting react hooks without rerendering code example
Example: rerender in hooks testing
import { renderHook, act } from '@testing-library/react-hooks'
import useCounter from './useCounter'
test('should reset counter to updated initial value', () => {
let initialValue = 0
const { result, rerender } = renderHook(() => useCounter(initialValue))
initialValue = 10
rerender()
act(() => {
result.current.reset()
})
expect(result.current.count).toBe(10)
})