GetRootNodeFragmentContainer.js — react Source File
Architecture documentation for GetRootNodeFragmentContainer.js, a javascript file in the react codebase. 0 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 8b34ee80_c1e9_f50b_9b1c_9fad0c8cbf2d["GetRootNodeFragmentContainer.js"] f361f511_643d_fef8_84d3_4e38e9129616["TextNodesCase.js"] f361f511_643d_fef8_84d3_4e38e9129616 --> 8b34ee80_c1e9_f50b_9b1c_9fad0c8cbf2d style 8b34ee80_c1e9_f50b_9b1c_9fad0c8cbf2d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
const React = window.React;
const {Fragment, useRef, useState} = React;
export default function GetRootNodeFragmentContainer({children}) {
const fragmentRef = useRef(null);
const [rootNodeInfo, setRootNodeInfo] = useState(null);
const getRootNodeInfo = () => {
const rootNode = fragmentRef.current.getRootNode();
setRootNodeInfo({
nodeName: rootNode.nodeName,
nodeType: rootNode.nodeType,
nodeTypeLabel: getNodeTypeLabel(rootNode.nodeType),
isDocument: rootNode === document,
});
};
const getNodeTypeLabel = nodeType => {
const types = {
1: 'ELEMENT_NODE',
3: 'TEXT_NODE',
9: 'DOCUMENT_NODE',
11: 'DOCUMENT_FRAGMENT_NODE',
};
return types[nodeType] || `UNKNOWN (${nodeType})`;
};
return (
<Fragment>
<div style={{marginBottom: '16px'}}>
<button
onClick={getRootNodeInfo}
style={{
padding: '8px 16px',
fontSize: '14px',
fontWeight: 'bold',
cursor: 'pointer',
}}>
Get Root Node
</button>
</div>
{rootNodeInfo && (
<div
style={{
marginBottom: '16px',
padding: '12px',
backgroundColor: '#e8f4e8',
border: '1px solid #9c9',
borderRadius: '4px',
fontFamily: 'monospace',
fontSize: '13px',
}}>
<div style={{marginBottom: '4px'}}>
<strong>Node Name:</strong> {rootNodeInfo.nodeName}
</div>
<div style={{marginBottom: '4px'}}>
<strong>Node Type:</strong> {rootNodeInfo.nodeType} (
{rootNodeInfo.nodeTypeLabel})
</div>
<div>
<strong>Is Document:</strong>{' '}
{rootNodeInfo.isDocument ? 'Yes' : 'No'}
</div>
</div>
)}
<div
style={{
padding: '12px',
border: '1px dashed #ccc',
borderRadius: '4px',
backgroundColor: '#fff',
}}>
<Fragment ref={fragmentRef}>{children}</Fragment>
</div>
</Fragment>
);
}
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does GetRootNodeFragmentContainer.js do?
GetRootNodeFragmentContainer.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in GetRootNodeFragmentContainer.js?
GetRootNodeFragmentContainer.js defines 1 function(s): GetRootNodeFragmentContainer.
What files import GetRootNodeFragmentContainer.js?
GetRootNodeFragmentContainer.js is imported by 1 file(s): TextNodesCase.js.
Where is GetRootNodeFragmentContainer.js in the architecture?
GetRootNodeFragmentContainer.js is located at fixtures/dom/src/components/fixtures/fragment-refs/GetRootNodeFragmentContainer.js (domain: BabelCompiler, subdomain: Optimization, directory: fixtures/dom/src/components/fixtures/fragment-refs).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free