Components() — react Function Reference
Architecture documentation for the Components() function in Components.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD f1044dd1_197d_f5ff_fe4b_853c7bf91daf["Components()"] a2fac529_5caa_fd15_61d0_e5b11d75bdd2["Components.js"] f1044dd1_197d_f5ff_fe4b_853c7bf91daf -->|defined in| a2fac529_5caa_fd15_61d0_e5b11d75bdd2 style f1044dd1_197d_f5ff_fe4b_853c7bf91daf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-shared/src/devtools/views/Components/Components.js lines 46–177
function Components(_: {}) {
const wrapperElementRef = useRef<null | HTMLElement>(null);
const resizeElementRef = useRef<null | HTMLElement>(null);
const [state, dispatch] = useReducer<ResizeState, any, ResizeAction>(
resizeReducer,
null,
initResizeState,
);
const {horizontalPercentage, verticalPercentage} = state;
useLayoutEffect(() => {
const resizeElement = resizeElementRef.current;
setResizeCSSVariable(
resizeElement,
'horizontal',
horizontalPercentage * 100,
);
setResizeCSSVariable(resizeElement, 'vertical', verticalPercentage * 100);
}, []);
useEffect(() => {
const timeoutID = setTimeout(() => {
localStorageSetItem(
LOCAL_STORAGE_KEY,
JSON.stringify({
horizontalPercentage,
verticalPercentage,
}),
);
}, 500);
return () => clearTimeout(timeoutID);
}, [horizontalPercentage, verticalPercentage]);
const onResizeStart = (event: SyntheticPointerEvent) => {
const element = event.currentTarget;
element.setPointerCapture(event.pointerId);
};
const onResizeEnd = (event: SyntheticPointerEvent) => {
const element = event.currentTarget;
element.releasePointerCapture(event.pointerId);
};
const onResize = (event: SyntheticPointerEvent) => {
const element = event.currentTarget;
const isResizing = element.hasPointerCapture(event.pointerId);
if (!isResizing) {
return;
}
const resizeElement = resizeElementRef.current;
const wrapperElement = wrapperElementRef.current;
if (wrapperElement === null || resizeElement === null) {
return;
}
event.preventDefault();
const orientation = getOrientation(wrapperElement);
const {height, width, left, top} = wrapperElement.getBoundingClientRect();
const currentMousePosition =
orientation === 'horizontal' ? event.clientX - left : event.clientY - top;
const boundaryMin = MINIMUM_SIZE;
const boundaryMax =
orientation === 'horizontal'
? width - MINIMUM_SIZE
: height - MINIMUM_SIZE;
const isMousePositionInBounds =
currentMousePosition > boundaryMin && currentMousePosition < boundaryMax;
if (isMousePositionInBounds) {
const resizedElementDimension =
Domain
Subdomains
Source
Frequently Asked Questions
What does Components() do?
Components() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/Components/Components.js.
Where is Components() defined?
Components() is defined in packages/react-devtools-shared/src/devtools/views/Components/Components.js at line 46.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free