# Data flow — testing-library/react-testing-library

> Canonical page: https://codevetter.com/unpack/react-testing-library/data-flow

# Data flow — testing-library/react-testing-library

Scanned commit 20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800 (2026-08-27). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

React nodes and render options enter the root orchestration layer, then become DOM content and query-bound results. Configuration and scheduling state are shared within the loaded modules and test global. Hook output and snapshots are transient outputs rather than durable persistence.
- render rejects a supplied onUncaughtError and unsupported legacyRoot before defaulting baseElement or allocating a container. — [src/pure.js#L238-L275](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L238-L275)
- A new container selects a root factory and records the root in both tracking structures; a known container retrieves its existing root by scanning mountedRootEntries. — [src/pure.js#L277-L304](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L277-L304)
- UI is first wrapped in the optional wrapper component, then optionally enclosed in StrictMode, before rendering or hydration inside act. — [src/pure.js#L90-L100](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L90-L100) [src/pure.js#L177-L195](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L177-L195)
- onCaughtError and onRecoverableError flow into createRoot or hydrateRoot at root creation; they are not supplied anew when an existing root is reused. — [src/pure.js#L114-L129](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L114-L129) [src/pure.js#L279-L303](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L279-L303)
- Queries bind to baseElement, whereas asFragment serializes container.innerHTML into a DocumentFragment and debug formats its selected element through prettyDOM. — [src/pure.js#L197-L205](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L197-L205) [src/pure.js#L222-L235](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L222-L235)
- configure evaluates functional deltas against merged configuration, forwards non-reactStrictMode fields to DOM Testing Library, and assigns reactStrictMode in RTL's local config. — [src/config.js#L10-L31](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/config.js#L10-L31)
- renderHook computes pendingResult during TestComponent rendering, publishes it to result.current in useEffect, and passes new rerender arguments as renderCallbackProps. — [src/pure.js#L343-L366](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L343-L366)
- cleanup unmounts roots inside act, removes only containers directly under document.body, and clears in-memory tracking; custom parent elements remain outside that removal boundary. — [src/pure.js#L317-L328](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L317-L328) [src/__tests__/multi-base.js#L5-L16](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/__tests__/multi-base.js#L5-L16)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
