MCPcopy Index your code
hub / github.com/epicweb-dev/react-performance / getComponentCalls

Function getComponentCalls

shared/get-component-calls.tsx:114–148  ·  view source on GitHub ↗
(cb: () => void | Promise<void>)

Source from the content-addressed store, hash-verified

112}
113
114export async function getComponentCalls(cb: () => void | Promise<void>) {
115 const componentNames: Array<string> = []
116 if (!internals) {
117 throw new Error('🚨 React DevTools is not available')
118 }
119
120 const supportsInjectedProfilingHooks =
121 typeof internals.injectProfilingHooks === 'function'
122
123 if (supportsInjectedProfilingHooks) {
124 internals.enableProfilerTimer = true
125 internals.enableProfilerCommitHooks = true
126 internals.injectProfilingHooks({
127 markComponentRenderStarted: (fiber: any) => {
128 componentNames.push(fiber.type.name || 'Anonymous')
129 },
130 })
131 } else {
132 activeFallbackComponentNames = componentNames
133 }
134
135 try {
136 await cb()
137 } finally {
138 if (supportsInjectedProfilingHooks) {
139 internals.enableProfilerTimer = false
140 internals.enableProfilerCommitHooks = false
141 internals.injectProfilingHooks(null)
142 } else {
143 activeFallbackComponentNames = null
144 }
145 }
146
147 return componentNames
148}
149
150if (window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
151 window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = enhanceExistingHook(

Callers 8

render.test.tsFile · 0.90
render.test.tsFile · 0.90
render.test.tsFile · 0.90
render.test.tsFile · 0.90
render.test.tsFile · 0.90
provider.test.tsFile · 0.90
split.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected