MCPcopy
hub / github.com/facebook/react / inspectHooks

Function inspectHooks

packages/react-devtools-shared/src/backend/fiber/renderer.js:5913–5937  ·  view source on GitHub ↗
(fiber: Fiber)

Source from the content-addressed store, hash-verified

5911 }
5912
5913 function inspectHooks(fiber: Fiber): HooksTree {
5914 const originalConsoleMethods: {[string]: $FlowFixMe} = {};
5915
5916 // Temporarily disable all console logging before re-running the hook.
5917 for (const method in console) {
5918 try {
5919 // $FlowFixMe[invalid-computed-prop]
5920 originalConsoleMethods[method] = console[method];
5921 // $FlowFixMe[prop-missing]
5922 console[method] = () => {};
5923 } catch (error) {}
5924 }
5925
5926 try {
5927 return inspectHooksOfFiber(fiber, getDispatcherRef(renderer));
5928 } finally {
5929 // Restore original console functionality.
5930 for (const method in originalConsoleMethods) {
5931 try {
5932 // $FlowFixMe[prop-missing]
5933 console[method] = originalConsoleMethods[method];
5934 } catch (error) {}
5935 }
5936 }
5937 }
5938
5939 function getSuspendedByOfSuspenseNode(
5940 suspenseNode: SuspenseNode,

Callers 3

inspectFiberInstanceRawFunction · 0.70
getHookNamesForComponentFunction · 0.50

Calls 2

inspectHooksOfFiberFunction · 0.90
getDispatcherRefFunction · 0.85

Tested by 1

getHookNamesForComponentFunction · 0.40