RenderHookOptions

Properties

Link copied to clipboard
abstract var baseElement: BaseElement?

Defaults to the container if the container is specified. Otherwise document.body is used for the default. This is used as the base element for the queries as well as what is printed when you use debug().

Link copied to clipboard
abstract var container: Container?

By default, React Testing Library will create a div and append that div to the document.body. Your React component will be rendered in the created div. If you provide your own HTMLElement container via this option, it will not be appended to the document.body automatically.

Link copied to clipboard
abstract var hydrate: Boolean?

If hydrate is set to true, then it will render with ReactDOM.hydrate. This may be useful if you are using server-side rendering and use ReactDOM.hydrate to mount your components.

Link copied to clipboard
abstract var initialProps: Props?

The argument passed to the renderHook callback. Can be useful if you plan to use the rerender utility to change the values passed to your hook.

Link copied to clipboard
abstract var legacyRoot: Boolean?

Only works if used with React 18. Set to true if you want to force synchronous ReactDOM.render. Otherwise render will default to concurrent React if available.

Link copied to clipboard
abstract var onCaughtError: Any

Only supported in React 19. Callback called when React catches an error in an Error Boundary. Called with the error caught by the Error Boundary, and an errorInfo object containing the componentStack.

Link copied to clipboard

Callback called when React automatically recovers from errors. Called with an error React throws, and an errorInfo object containing the componentStack. Some recoverable errors may include the original error cause as error.cause.

Link copied to clipboard
abstract var onUncaughtError: Nothing?

Not supported at the moment

Link copied to clipboard
abstract var queries: Queries?

Queries to bind. Overrides the default set from DOM Testing Library unless merged.

Link copied to clipboard
abstract var reactStrictMode: Boolean?

When enabled, is rendered around the inner element. If defined, overrides the value of reactStrictMode set in configure.

Link copied to clipboard
abstract var wrapper: Any

Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating reusable custom render functions for common data providers. See setup for examples.