Skip to content

Commit 5a1e696

Browse files
committed
.
1 parent ec3fbe9 commit 5a1e696

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/render-hook.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function renderHook<Result, Props>(
4040
hookToRender: (props: Props) => Result,
4141
options?: RenderHookOptions<Props>,
4242
): RenderHookResult<Result, Props> {
43-
const result = React.createRef<Result>();
43+
const result = React.createRef<Result>() as RefObject<Result>;
4444

4545
function HookContainer({ hookProps }: { hookProps: Props }) {
4646
const renderResult = hookToRender(hookProps);
@@ -59,8 +59,7 @@ export function renderHook<Result, Props>(
5959
);
6060

6161
return {
62-
// Result should already be set after the first render effects are run.
63-
result: result as RefObject<Result>,
62+
result: result,
6463
rerender: (hookProps: Props) => rerenderComponent(<HookContainer hookProps={hookProps} />),
6564
unmount,
6665
};
@@ -70,7 +69,7 @@ export async function renderHookAsync<Result, Props>(
7069
hookToRender: (props: Props) => Result,
7170
options?: RenderHookOptions<Props>,
7271
): Promise<RenderHookAsyncResult<Result, Props>> {
73-
const result = React.createRef<Result>();
72+
const result = React.createRef<Result>() as RefObject<Result>;
7473

7574
function TestComponent({ hookProps }: { hookProps: Props }) {
7675
const renderResult = hookToRender(hookProps);
@@ -89,8 +88,7 @@ export async function renderHookAsync<Result, Props>(
8988
);
9089

9190
return {
92-
// Result should already be set after the first render effects are run.
93-
result: result as RefObject<Result>,
91+
result: result,
9492
rerenderAsync: (hookProps: Props) =>
9593
rerenderComponentAsync(<TestComponent hookProps={hookProps} />),
9694
unmountAsync,

0 commit comments

Comments
 (0)