validateNoJSXInTryStatement() — react Function Reference
Architecture documentation for the validateNoJSXInTryStatement() function in ValidateNoJSXInTryStatement.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 098764b0_1542_854b_0a71_e361ec33cef2["validateNoJSXInTryStatement()"] e270e40b_ce98_5d39_9c94_07445e9a0ce8["ValidateNoJSXInTryStatement.ts"] 098764b0_1542_854b_0a71_e361ec33cef2 -->|defined in| e270e40b_ce98_5d39_9c94_07445e9a0ce8 c3bc3875_256f_8f5e_7800_2f9c5bae65eb["runWithEnvironment()"] c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 098764b0_1542_854b_0a71_e361ec33cef2 c447b97e_0b8e_b187_e3a8_4be412d6f495["retainWhere()"] 098764b0_1542_854b_0a71_e361ec33cef2 -->|calls| c447b97e_0b8e_b187_e3a8_4be412d6f495 02303def_636f_c5b3_a751_1cf138fcea69["pushDiagnostic()"] 098764b0_1542_854b_0a71_e361ec33cef2 -->|calls| 02303def_636f_c5b3_a751_1cf138fcea69 ac13f5c1_be17_dd7a_6bd3_66d91c46aadf["create()"] 098764b0_1542_854b_0a71_e361ec33cef2 -->|calls| ac13f5c1_be17_dd7a_6bd3_66d91c46aadf 1a2b7047_24c8_62d6_b328_5f07307d27ab["withDetails()"] 098764b0_1542_854b_0a71_e361ec33cef2 -->|calls| 1a2b7047_24c8_62d6_b328_5f07307d27ab 073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"] 098764b0_1542_854b_0a71_e361ec33cef2 -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83 531eb985_e192_f9a2_2d7b_5deeb85ba95c["asResult()"] 098764b0_1542_854b_0a71_e361ec33cef2 -->|calls| 531eb985_e192_f9a2_2d7b_5deeb85ba95c style 098764b0_1542_854b_0a71_e361ec33cef2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoJSXInTryStatement.ts lines 24–60
export function validateNoJSXInTryStatement(
fn: HIRFunction,
): Result<void, CompilerError> {
const activeTryBlocks: Array<BlockId> = [];
const errors = new CompilerError();
for (const [, block] of fn.body.blocks) {
retainWhere(activeTryBlocks, id => id !== block.id);
if (activeTryBlocks.length !== 0) {
for (const instr of block.instructions) {
const {value} = instr;
switch (value.kind) {
case 'JsxExpression':
case 'JsxFragment': {
errors.pushDiagnostic(
CompilerDiagnostic.create({
category: ErrorCategory.ErrorBoundaries,
reason: 'Avoid constructing JSX within try/catch',
description: `React does not immediately render components when JSX is rendered, so any errors from this component will not be caught by the try/catch. To catch errors in rendering a given component, wrap that component in an error boundary. (https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary)`,
}).withDetails({
kind: 'error',
loc: value.loc,
message: 'Avoid constructing JSX within try/catch',
}),
);
break;
}
}
}
}
if (block.terminal.kind === 'try') {
activeTryBlocks.push(block.terminal.handler);
}
}
return errors.asResult();
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does validateNoJSXInTryStatement() do?
validateNoJSXInTryStatement() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoJSXInTryStatement.ts.
Where is validateNoJSXInTryStatement() defined?
validateNoJSXInTryStatement() is defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoJSXInTryStatement.ts at line 24.
What does validateNoJSXInTryStatement() call?
validateNoJSXInTryStatement() calls 6 function(s): asResult, create, push, pushDiagnostic, retainWhere, withDetails.
What calls validateNoJSXInTryStatement()?
validateNoJSXInTryStatement() is called by 1 function(s): runWithEnvironment.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free