MCPcopy Index your code
hub / github.com/react/react / attachRenderer

Function attachRenderer

packages/react-devtools-shared/src/attachRenderer.js:28–71  ·  view source on GitHub ↗
(
  hook: DevToolsHook,
  id: RendererID,
  renderer: ReactRenderer,
  global: Object,
  shouldStartProfilingNow: boolean,
  profilingSettings: ProfilingSettings,
)

Source from the content-addressed store, hash-verified

26}
27
28export default function attachRenderer(
29 hook: DevToolsHook,
30 id: RendererID,
31 renderer: ReactRenderer,
32 global: Object,
33 shouldStartProfilingNow: boolean,
34 profilingSettings: ProfilingSettings,
35): RendererInterface | void {
36 // only attach if the renderer is compatible with the current version of the backend
37 if (!isMatchingRender(renderer.reconcilerVersion || renderer.version)) {
38 return;
39 }
40 let rendererInterface = hook.rendererInterfaces.get(id);
41
42 // Inject any not-yet-injected renderers (if we didn't reload-and-profile)
43 if (rendererInterface == null) {
44 if (typeof renderer.getCurrentComponentInfo === 'function') {
45 // react-flight/client
46 rendererInterface = attachFlight(hook, id, renderer, global);
47 } else if (
48 // v16-19
49 typeof renderer.findFiberByHostInstance === 'function' ||
50 // v16.8+
51 renderer.currentDispatcherRef != null
52 ) {
53 // react-reconciler v16+
54 rendererInterface = attachFiber(
55 hook,
56 id,
57 renderer,
58 global,
59 shouldStartProfilingNow,
60 profilingSettings,
61 );
62 } else if (renderer.ComponentTree) {
63 // react-dom v15
64 rendererInterface = attachLegacy(hook, id, renderer, global);
65 } else {
66 // Older react-dom or other unsupported renderer version
67 }
68 }
69
70 return rendererInterface;
71}

Callers 1

injectFunction · 0.85

Calls 2

isMatchingRenderFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected