printStore() — react Function Reference
Architecture documentation for the printStore() function in utils.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD d738af75_576c_a12f_4a3a_c9e3cfe329a7["printStore()"] fa31bba5_57ed_1039_52bb_4a8cb4382642["utils.js"] d738af75_576c_a12f_4a3a_c9e3cfe329a7 -->|defined in| fa31bba5_57ed_1039_52bb_4a8cb4382642 3900d299_1b5e_8f06_db86_8036ae03467a["printElement()"] d738af75_576c_a12f_4a3a_c9e3cfe329a7 -->|calls| 3900d299_1b5e_8f06_db86_8036ae03467a 9e791acc_1fb9_a677_caed_88191a0f766b["printRects()"] d738af75_576c_a12f_4a3a_c9e3cfe329a7 -->|calls| 9e791acc_1fb9_a677_caed_88191a0f766b ae59a0ab_8058_50ec_939d_2f5c2fbce4f2["printSuspenseWithChildren()"] d738af75_576c_a12f_4a3a_c9e3cfe329a7 -->|calls| ae59a0ab_8058_50ec_939d_2f5c2fbce4f2 style d738af75_576c_a12f_4a3a_c9e3cfe329a7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-shared/src/devtools/utils.js lines 100–210
export function printStore(
store: Store,
includeWeight: boolean = false,
state: StateContext | null = null,
includeSuspense: boolean = true,
): string {
const snapshotLines = [];
let rootWeight = 0;
function printSelectedMarker(index: number): string {
if (state === null) {
return '';
}
return state.inspectedElementIndex === index ? `→` : ' ';
}
function printErrorsAndWarnings(element: Element): string {
const {errorCount, warningCount} =
store.getErrorAndWarningCountForElementID(element.id);
if (errorCount === 0 && warningCount === 0) {
return '';
}
return ` ${errorCount > 0 ? '✕' : ''}${warningCount > 0 ? '⚠' : ''}`;
}
const ownerFlatTree = state !== null ? state.ownerFlatTree : null;
if (ownerFlatTree !== null) {
snapshotLines.push(
'[owners]' + (includeWeight ? ` (${ownerFlatTree.length})` : ''),
);
ownerFlatTree.forEach((element, index) => {
const printedSelectedMarker = printSelectedMarker(index);
const printedElement = printElement(element, false);
const printedErrorsAndWarnings = printErrorsAndWarnings(element);
snapshotLines.push(
`${printedSelectedMarker}${printedElement}${printedErrorsAndWarnings}`,
);
});
} else {
const errorsAndWarnings = store._errorsAndWarnings;
if (errorsAndWarnings.size > 0) {
let errorCount = 0;
let warningCount = 0;
errorsAndWarnings.forEach(entry => {
errorCount += entry.errorCount;
warningCount += entry.warningCount;
});
snapshotLines.push(`✕ ${errorCount}, ⚠ ${warningCount}`);
}
store.roots.forEach(rootID => {
const {weight} = ((store.getElementByID(rootID): any): Element);
const maybeWeightLabel = includeWeight ? ` (${weight})` : '';
// Store does not (yet) expose a way to get errors/warnings per root.
snapshotLines.push(`[root]${maybeWeightLabel}`);
for (let i = rootWeight; i < rootWeight + weight; i++) {
const element = store.getElementAtIndex(i);
if (element == null) {
throw Error(`Could not find element at index "${i}"`);
}
const printedSelectedMarker = printSelectedMarker(i);
const printedElement = printElement(element, includeWeight);
const printedErrorsAndWarnings = printErrorsAndWarnings(element);
snapshotLines.push(
`${printedSelectedMarker}${printedElement}${printedErrorsAndWarnings}`,
);
}
rootWeight += weight;
if (includeSuspense) {
const root = store.getSuspenseByID(rootID);
// Roots from legacy renderers don't have a separate Suspense tree
if (root !== null) {
if (root.children.length > 0) {
Domain
Subdomains
Source
Frequently Asked Questions
What does printStore() do?
printStore() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/utils.js.
Where is printStore() defined?
printStore() is defined in packages/react-devtools-shared/src/devtools/utils.js at line 100.
What does printStore() call?
printStore() calls 3 function(s): printElement, printRects, printSuspenseWithChildren.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free