@@ -40,7 +40,7 @@ export function renderHook<Result, Props>(
40
40
hookToRender : ( props : Props ) => Result ,
41
41
options ?: RenderHookOptions < Props > ,
42
42
) : RenderHookResult < Result , Props > {
43
- const result = React . createRef < Result > ( ) ;
43
+ const result = React . createRef < Result > ( ) as RefObject < Result > ;
44
44
45
45
function HookContainer ( { hookProps } : { hookProps : Props } ) {
46
46
const renderResult = hookToRender ( hookProps ) ;
@@ -59,8 +59,7 @@ export function renderHook<Result, Props>(
59
59
) ;
60
60
61
61
return {
62
- // Result should already be set after the first render effects are run.
63
- result : result as RefObject < Result > ,
62
+ result : result ,
64
63
rerender : ( hookProps : Props ) => rerenderComponent ( < HookContainer hookProps = { hookProps } /> ) ,
65
64
unmount,
66
65
} ;
@@ -70,7 +69,7 @@ export async function renderHookAsync<Result, Props>(
70
69
hookToRender : ( props : Props ) => Result ,
71
70
options ?: RenderHookOptions < Props > ,
72
71
) : Promise < RenderHookAsyncResult < Result , Props > > {
73
- const result = React . createRef < Result > ( ) ;
72
+ const result = React . createRef < Result > ( ) as RefObject < Result > ;
74
73
75
74
function TestComponent ( { hookProps } : { hookProps : Props } ) {
76
75
const renderResult = hookToRender ( hookProps ) ;
@@ -89,8 +88,7 @@ export async function renderHookAsync<Result, Props>(
89
88
) ;
90
89
91
90
return {
92
- // Result should already be set after the first render effects are run.
93
- result : result as RefObject < Result > ,
91
+ result : result ,
94
92
rerenderAsync : ( hookProps : Props ) =>
95
93
rerenderComponentAsync ( < TestComponent hookProps = { hookProps } /> ) ,
96
94
unmountAsync,
0 commit comments