@@ -4,7 +4,7 @@ import {render as baseRender, RenderOptions} from '@testing-library/react'
4
4
import { Assertable , markAssertable } from '../assertable.js'
5
5
import { RenderInstance , type Render , type BaseRender } from './Render.js'
6
6
import { type RenderStreamContextValue } from './context.js'
7
- import { RenderStreamContextProvider , useRenderStreamContext } from './context.js'
7
+ import { RenderStreamContextProvider } from './context.js'
8
8
import { disableActWarnings } from './disableActWarnings.js'
9
9
10
10
export type ValidSnapshot =
@@ -337,42 +337,6 @@ export function createRenderStream<Snapshot extends ValidSnapshot = void>({
337
337
return stream
338
338
}
339
339
340
- function resolveR18HookOwner ( ) : React . ComponentType | undefined {
341
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
342
- return ( React as any ) . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
343
- ?. ReactCurrentOwner ?. current ?. elementType
344
- }
345
-
346
- function resolveR19HookOwner ( ) : React . ComponentType | undefined {
347
- /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */
348
- return (
349
- React as any
350
- ) . __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ?. A ?. getOwner ( )
351
- . elementType
352
- }
353
-
354
- export function useTrackRenders ( { name} : { name ?: string } = { } ) {
355
- const component = name ?? resolveR18HookOwner ( ) ?? resolveR19HookOwner ( )
356
-
357
- if ( ! component ) {
358
- throw new Error (
359
- 'useTrackRenders: Unable to determine component. Please ensure the hook is called inside a rendered component or provide a `name` option.' ,
360
- )
361
- }
362
-
363
- const ctx = useRenderStreamContext ( )
364
-
365
- if ( ! ctx ) {
366
- throw new Error (
367
- 'useTrackRenders: A Render Stream must be created and rendered to track component renders' ,
368
- )
369
- }
370
-
371
- React . useLayoutEffect ( ( ) => {
372
- ctx . renderedComponents . unshift ( component )
373
- } )
374
- }
375
-
376
340
function rethrowWithCapturedStackTrace ( constructorOpt : Function | undefined ) {
377
341
return function catchFn ( error : unknown ) {
378
342
if ( error instanceof Object ) {
0 commit comments