makeSwitchCaseBody() — react Function Reference
Architecture documentation for the makeSwitchCaseBody() function in code-path-state.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD ee07b2fc_7180_3458_2bdf_5fc6bb04b377["makeSwitchCaseBody()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c["CodePathState"] ee07b2fc_7180_3458_2bdf_5fc6bb04b377 -->|defined in| d3cee22c_5e2d_f853_c075_2c7c55e5d22c fcc7c411_4c84_b9a2_79b5_df3d388d50fc["pushForkContext()"] ee07b2fc_7180_3458_2bdf_5fc6bb04b377 -->|calls| fcc7c411_4c84_b9a2_79b5_df3d388d50fc style ee07b2fc_7180_3458_2bdf_5fc6bb04b377 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js lines 712–750
makeSwitchCaseBody(isEmpty, isDefault) {
const context = this.switchContext;
if (!context.hasCase) {
return;
}
/*
* Merge forks.
* The parent fork context has two segments.
* Those are from the current case and the body of the previous case.
*/
const parentForkContext = this.forkContext;
const forkContext = this.pushForkContext();
forkContext.add(parentForkContext.makeNext(0, -1));
/*
* Save `default` chunk info.
* If the `default` label is not at the last, we must make a path from
* the last `case` to the `default` chunk.
*/
if (isDefault) {
context.defaultSegments = parentForkContext.head;
if (isEmpty) {
context.foundDefault = true;
} else {
context.defaultBodySegments = forkContext.head;
}
} else {
if (!isEmpty && context.foundDefault) {
context.foundDefault = false;
context.defaultBodySegments = forkContext.head;
}
}
context.lastIsDefault = isDefault;
context.countForks += 1;
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does makeSwitchCaseBody() do?
makeSwitchCaseBody() is a function in the react codebase, defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js.
Where is makeSwitchCaseBody() defined?
makeSwitchCaseBody() is defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js at line 712.
What does makeSwitchCaseBody() call?
makeSwitchCaseBody() calls 1 function(s): pushForkContext.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free