@@ -2,15 +2,16 @@ import * as React from 'react';
22
33import render from './render' ;
44import renderAsync from './render-async' ;
5+ import type { RefObject } from './types' ;
56
67export type RenderHookResult < Result , Props > = {
7- result : React . RefObject < Result > ;
8+ result : RefObject < Result > ;
89 rerender : ( props : Props ) => void ;
910 unmount : ( ) => void ;
1011} ;
1112
1213export type RenderHookAsyncResult < Result , Props > = {
13- result : React . RefObject < Result > ;
14+ result : RefObject < Result > ;
1415 rerenderAsync : ( props : Props ) => Promise < void > ;
1516 unmountAsync : ( ) => Promise < void > ;
1617} ;
@@ -39,7 +40,7 @@ export function renderHook<Result, Props>(
3940 hookToRender : ( props : Props ) => Result ,
4041 options ?: RenderHookOptions < Props > ,
4142) : RenderHookResult < Result , Props > {
42- const result : React . RefObject < Result | null > = React . createRef ( ) ;
43+ const result = React . createRef < Result > ( ) ;
4344
4445 function HookContainer ( { hookProps } : { hookProps : Props } ) {
4546 const renderResult = hookToRender ( hookProps ) ;
@@ -59,7 +60,7 @@ export function renderHook<Result, Props>(
5960
6061 return {
6162 // 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 > ,
6364 rerender : ( hookProps : Props ) => rerenderComponent ( < HookContainer hookProps = { hookProps } /> ) ,
6465 unmount,
6566 } ;
@@ -69,7 +70,7 @@ export async function renderHookAsync<Result, Props>(
6970 hookToRender : ( props : Props ) => Result ,
7071 options ?: RenderHookOptions < Props > ,
7172) : Promise < RenderHookAsyncResult < Result , Props > > {
72- const result : React . RefObject < Result | null > = React . createRef ( ) ;
73+ const result = React . createRef < Result > ( ) ;
7374
7475 function TestComponent ( { hookProps } : { hookProps : Props } ) {
7576 const renderResult = hookToRender ( hookProps ) ;
@@ -89,7 +90,7 @@ export async function renderHookAsync<Result, Props>(
8990
9091 return {
9192 // 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 > ,
9394 rerenderAsync : ( hookProps : Props ) =>
9495 rerenderComponentAsync ( < TestComponent hookProps = { hookProps } /> ) ,
9596 unmountAsync,
0 commit comments