From 3b4c9b611373627f065e20088c75c136314a701a Mon Sep 17 00:00:00 2001 From: ssi02014 Date: Mon, 9 Oct 2023 16:32:40 +0900 Subject: [PATCH] fix: renderHook docs --- docs/react-testing-library/api.mdx | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/react-testing-library/api.mdx b/docs/react-testing-library/api.mdx index 4b1876dc7..9d95cd584 100644 --- a/docs/react-testing-library/api.mdx +++ b/docs/react-testing-library/api.mdx @@ -333,9 +333,15 @@ component results in more readable and robust tests since the thing you want to test is not hidden behind an abstraction. ```typescript -function renderHook( - render: (props: Props) => Result, - options?: RenderHookOptions, +function renderHook< + Result, + Props, + Q extends Queries = typeof queries, + Container extends Element | DocumentFragment = HTMLElement, + BaseElement extends Element | DocumentFragment = Container, +>( + render: (initialProps: Props) => Result, + options?: RenderHookOptions, ): RenderHookResult ``` @@ -431,3 +437,15 @@ const {rerender} = renderHook(({name = 'Alice'} = {}) => name) // re-render the same hook with different props rerender({name: 'Bob'}) ``` + +### `unmount` + +Unmounts the test hook. + +```jsx +import {renderHook} from '@testing-library/react' + +const {unmount} = renderHook(({name = 'Alice'} = {}) => name) + +unmount() +``` \ No newline at end of file