try-catch-optional-call.js — react Source File
Architecture documentation for try-catch-optional-call.js, a javascript file in the react codebase.
Entity Profile
Relationship Graph
Source Code
function Component({obj, arg}) {
try {
// arg.value is accessed WITHIN the optional call expression as an argument
// When obj is non-null but arg is null, arg.value throws inside the optional chain
const result = obj?.method?.(arg.value);
return <span>{result ?? 'no result'}</span>;
} catch {
return <span>error</span>;
}
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{obj: {method: x => 'called:' + x}, arg: {value: 1}}],
sequentialRenders: [
{obj: {method: x => 'called:' + x}, arg: {value: 1}},
{obj: {method: x => 'called:' + x}, arg: {value: 1}},
{obj: {method: x => 'different:' + x}, arg: {value: 2}},
{obj: {method: null}, arg: {value: 3}},
{obj: {notMethod: true}, arg: {value: 4}},
{obj: null, arg: {value: 5}}, // obj is null, short-circuits so arg.value is NOT evaluated
{obj: {method: x => 'test:' + x}, arg: null}, // errors because arg.value throws WITHIN the optional call
],
};
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does try-catch-optional-call.js do?
try-catch-optional-call.js is a source file in the react codebase, written in javascript. It belongs to the TestingUtilities domain, Fixtures subdomain.
What functions are defined in try-catch-optional-call.js?
try-catch-optional-call.js defines 1 function(s): Component.
Where is try-catch-optional-call.js in the architecture?
try-catch-optional-call.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/try-catch-optional-call.js (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free