Skip to content

API Reference / @gtkx/testing / renderHook

Function: renderHook() ​

Call Signature ​

renderHook<Result>(callback, options?): Promise<RenderHookResult<Result, undefined>>

Defined in: packages/testing/src/render-hook.tsx:13

Renders a test component that calls the given hook, exposing its latest return value along with rerender and unmount controls.

Type Parameters ​

Result ​

Result

Parameters ​

callback ​

() => Result

The hook to run, invoked with the current props.

options? ​

RenderHookOptions<undefined>

Optional initial props and wrapper component.

Returns ​

Promise<RenderHookResult<Result, undefined>>

A result whose result.current holds the hook's latest value.

Call Signature ​

renderHook<Result, Props>(callback, options): Promise<RenderHookResult<Result, Props>>

Defined in: packages/testing/src/render-hook.tsx:26

Renders a test component that calls the given hook with props, exposing its latest return value along with rerender and unmount controls.

Type Parameters ​

Result ​

Result

Props ​

Props

Parameters ​

callback ​

(props) => Result

The hook to run, invoked with the current props.

options ​

RenderHookOptions<Props>

Initial props and optional wrapper component.

Returns ​

Promise<RenderHookResult<Result, Props>>

A result whose result.current holds the hook's latest value.