@@ -2,15 +2,16 @@ import * as React from 'react';
2
2
3
3
import render from './render' ;
4
4
import renderAsync from './render-async' ;
5
+ import type { RefObject } from './types' ;
5
6
6
7
export type RenderHookResult < Result , Props > = {
7
- result : React . RefObject < Result > ;
8
+ result : RefObject < Result > ;
8
9
rerender : ( props : Props ) => void ;
9
10
unmount : ( ) => void ;
10
11
} ;
11
12
12
13
export type RenderHookAsyncResult < Result , Props > = {
13
- result : React . RefObject < Result > ;
14
+ result : RefObject < Result > ;
14
15
rerenderAsync : ( props : Props ) => Promise < void > ;
15
16
unmountAsync : ( ) => Promise < void > ;
16
17
} ;
@@ -39,7 +40,7 @@ export function renderHook<Result, Props>(
39
40
hookToRender : ( props : Props ) => Result ,
40
41
options ?: RenderHookOptions < Props > ,
41
42
) : RenderHookResult < Result , Props > {
42
- const result : React . RefObject < Result | null > = React . createRef ( ) ;
43
+ const result = React . createRef < Result > ( ) ;
43
44
44
45
function HookContainer ( { hookProps } : { hookProps : Props } ) {
45
46
const renderResult = hookToRender ( hookProps ) ;
@@ -59,7 +60,7 @@ export function renderHook<Result, Props>(
59
60
60
61
return {
61
62
// Result should already be set after the first render effects are run.
62
- result : result as React . RefObject < Result > ,
63
+ result : result as RefObject < Result > ,
63
64
rerender : ( hookProps : Props ) => rerenderComponent ( < HookContainer hookProps = { hookProps } /> ) ,
64
65
unmount,
65
66
} ;
@@ -69,7 +70,7 @@ export async function renderHookAsync<Result, Props>(
69
70
hookToRender : ( props : Props ) => Result ,
70
71
options ?: RenderHookOptions < Props > ,
71
72
) : Promise < RenderHookAsyncResult < Result , Props > > {
72
- const result : React . RefObject < Result | null > = React . createRef ( ) ;
73
+ const result = React . createRef < Result > ( ) ;
73
74
74
75
function TestComponent ( { hookProps } : { hookProps : Props } ) {
75
76
const renderResult = hookToRender ( hookProps ) ;
@@ -89,7 +90,7 @@ export async function renderHookAsync<Result, Props>(
89
90
90
91
return {
91
92
// Result should already be set after the first render effects are run.
92
- result : result as React . RefObject < Result > ,
93
+ result : result as RefObject < Result > ,
93
94
rerenderAsync : ( hookProps : Props ) =>
94
95
rerenderComponentAsync ( < TestComponent hookProps = { hookProps } /> ) ,
95
96
unmountAsync,
0 commit comments