createDiagnostic() — react Function Reference
Architecture documentation for the createDiagnostic() function in ValidateExhaustiveDependencies.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD ad16c945_f474_200d_7fb0_0ec722c7bc17["createDiagnostic()"] fe7a7397_dddc_7222_20d4_d5b1015466f1["ValidateExhaustiveDependencies.ts"] ad16c945_f474_200d_7fb0_0ec722c7bc17 -->|defined in| fe7a7397_dddc_7222_20d4_d5b1015466f1 6869984f_c56b_62c6_1328_06ff93395ab4["validateDependencies()"] 6869984f_c56b_62c6_1328_06ff93395ab4 -->|calls| ad16c945_f474_200d_7fb0_0ec722c7bc17 041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"] ad16c945_f474_200d_7fb0_0ec722c7bc17 -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e ac13f5c1_be17_dd7a_6bd3_66d91c46aadf["create()"] ad16c945_f474_200d_7fb0_0ec722c7bc17 -->|calls| ac13f5c1_be17_dd7a_6bd3_66d91c46aadf style ad16c945_f474_200d_7fb0_0ec722c7bc17 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateExhaustiveDependencies.ts lines 1053–1112
function createDiagnostic(
category:
| ErrorCategory.MemoDependencies
| ErrorCategory.EffectExhaustiveDependencies,
missing: Array<InferredDependency>,
extra: Array<ManualMemoDependency>,
suggestion: CompilerSuggestion | null,
): CompilerDiagnostic {
let reason: string;
let description: string;
function joinMissingExtraDetail(
missingString: string,
extraString: string,
joinStr: string,
): string {
return [
missing.length !== 0 ? missingString : null,
extra.length !== 0 ? extraString : null,
]
.filter(Boolean)
.join(joinStr);
}
switch (category) {
case ErrorCategory.MemoDependencies: {
reason = `Found ${joinMissingExtraDetail('missing', 'extra', '/')} memoization dependencies`;
description = joinMissingExtraDetail(
'Missing dependencies can cause a value to update less often than it should, resulting in stale UI',
'Extra dependencies can cause a value to update more often than it should, resulting in performance' +
' problems such as excessive renders or effects firing too often',
'. ',
);
break;
}
case ErrorCategory.EffectExhaustiveDependencies: {
reason = `Found ${joinMissingExtraDetail('missing', 'extra', '/')} effect dependencies`;
description = joinMissingExtraDetail(
'Missing dependencies can cause an effect to fire less often than it should',
'Extra dependencies can cause an effect to fire more often than it should, resulting' +
' in performance problems such as excessive renders and side effects',
'. ',
);
break;
}
default: {
CompilerError.invariant(false, {
reason: `Unexpected error category: ${category}`,
loc: GeneratedSource,
});
}
}
return CompilerDiagnostic.create({
category,
reason,
description,
suggestions: suggestion != null ? [suggestion] : null,
});
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does createDiagnostic() do?
createDiagnostic() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateExhaustiveDependencies.ts.
Where is createDiagnostic() defined?
createDiagnostic() is defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateExhaustiveDependencies.ts at line 1053.
What does createDiagnostic() call?
createDiagnostic() calls 2 function(s): create, invariant.
What calls createDiagnostic()?
createDiagnostic() is called by 1 function(s): validateDependencies.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free