From f7b922982f0b39e4e09cd2f484cee3dc640fd0a4 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Mon, 13 Jan 2025 13:38:34 -0700 Subject: [PATCH] fix: Make props optional in `rerender` function returned from `renderHookToSnapshotStream` --- src/renderHookToSnapshotStream.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/renderHookToSnapshotStream.tsx b/src/renderHookToSnapshotStream.tsx index ecf62d382..cbc798aad 100644 --- a/src/renderHookToSnapshotStream.tsx +++ b/src/renderHookToSnapshotStream.tsx @@ -41,27 +41,27 @@ export interface SnapshotStream extends Assertable { * Does not advance the render iterator. */ waitForNextSnapshot(options?: NextRenderOptions): Promise - rerender: (rerenderCallbackProps: Props) => Promise + rerender: (rerenderCallbackProps?: Props) => Promise unmount: () => void } export async function renderHookToSnapshotStream( - renderCallback: (props: Props) => ReturnValue, + renderCallback: (props?: Props) => ReturnValue, {initialProps, ...renderOptions}: RenderHookOptions = {}, ): Promise> { const {render, ...stream} = createRenderStream<{value: ReturnValue}, never>() - const HookComponent: React.FC<{arg: Props}> = props => { + const HookComponent: React.FC<{arg?: Props}> = props => { stream.replaceSnapshot({value: renderCallback(props.arg)}) return null } const {rerender: baseRerender, unmount} = await render( - , + , renderOptions, ) - function rerender(rerenderCallbackProps: Props) { + function rerender(rerenderCallbackProps?: Props) { return baseRerender() }