Skip to content

Commit 144b485

Browse files
committed
fix types and add docs
1 parent 55811ff commit 144b485

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

types/index.d.ts

+32-5
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,47 @@ export function render(
9898
options?: Omit<RenderOptions, 'queries'>,
9999
): RenderResult
100100

101-
// TODO JSDOC
102101
interface RenderHookResult<Result, Props> {
102+
/**
103+
* Triggers a re-render. The props will be passed to your renderHook callback.
104+
*/
103105
rerender: (props?: Props) => void
104-
result: {current: Result}
106+
/**
107+
* This is a stable reference to the latest value returned by your renderHook
108+
* callback
109+
*/
110+
result: {
111+
/**
112+
* The value returned by your renderHook callback
113+
*/
114+
current: Result
115+
}
116+
/**
117+
* Unmounts the test component. This is useful for when you need to test
118+
* any cleanup your useEffects have.
119+
*/
105120
unmount: () => void
106121
}
107122

108-
// TODO JSDOC
109123
interface RenderHookOptions<Props> {
124+
/**
125+
* The argument passed to the renderHook callback. Can be useful if you plan
126+
* to use the rerender utility to change the values passed to your hook.
127+
*/
110128
initialProps?: Props
111-
wrapper?: React.ComponentType
129+
/**
130+
* Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating
131+
* reusable custom render functions for common data providers. See setup for examples.
132+
*
133+
* @see https://testing-library.com/docs/react-testing-library/api/#wrapper
134+
*/
135+
wrapper?: React.JSXElementConstructor<{children: React.ReactElement}>
112136
}
113137

114-
// TODO JSDOC
138+
/**
139+
* Allows you to render a hook within a test React component without having to
140+
* create that component yourself.
141+
*/
115142
export function renderHook<Result, Props>(
116143
render: (initialProps: Props) => Result,
117144
options?: RenderHookOptions<Props>,

0 commit comments

Comments
 (0)