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

Function getData

packages/react-devtools-shared/src/backend/legacy/renderer.js:62–84  ·  view source on GitHub ↗
(internalInstance: InternalInstance)

Source from the content-addressed store, hash-verified

60type LegacyRenderer = Object;
61
62function getData(internalInstance: InternalInstance) {
63 let displayName = null;
64 let key = null;
65
66 // != used deliberately here to catch undefined and null
67 if (internalInstance._currentElement != null) {
68 if (internalInstance._currentElement.key) {
69 key = String(internalInstance._currentElement.key);
70 }
71
72 const elementType = internalInstance._currentElement.type;
73 if (typeof elementType === 'string') {
74 displayName = elementType;
75 } else if (typeof elementType === 'function') {
76 displayName = getDisplayName(elementType);
77 }
78 }
79
80 return {
81 displayName,
82 key,
83 };
84}
85
86function getElementType(internalInstance: InternalInstance): ElementType {
87 // != used deliberately here to catch undefined and null

Callers 3

recordMountFunction · 0.70
inspectElementRawFunction · 0.70

Calls 1

getDisplayNameFunction · 0.90

Tested by

no test coverage detected