function-with-conditional-callsite-in-another-function.ts — react Source File
Architecture documentation for function-with-conditional-callsite-in-another-function.ts, a typescript file in the react codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 553b839c_05ff_97a6_8f76_7a273364819c["function-with-conditional-callsite-in-another-function.ts"] 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"] 553b839c_05ff_97a6_8f76_7a273364819c --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05 style 553b839c_05ff_97a6_8f76_7a273364819c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import {createHookWrapper} from 'shared-runtime';
/**
* (Given that the returned lambda is assumed to be invoked, see
* return-function)
*
* If lambda A conditionally calls lambda B, optimistically assume that property
* loads from lambda B has the same hoistability of ones from lambda A. This
* helps optimize components / hooks that create and chain many helper
* functions.
*
* Type systems and code readability encourage developers to colocate length and
* null checks values in the same function as where values are used. i.e.
* developers are unlikely to write the following code.
* ```js
* function useFoo(obj, objNotNullAndHasElements) {
* // ...
* const get0th = () => obj.arr[0].value;
* return () => objNotNullAndHasElements ? get0th : undefined;
* }
* ```
*
* In Meta code, this assumption helps reduce the number of memo dependency
* deopts.
*/
function useMakeCallback({
obj,
cond,
setState,
}: {
obj: {value: number};
cond: boolean;
setState: (newState: number) => void;
}) {
const cb = () => setState(obj.value);
// cb's property loads are assumed to be hoistable to the start of this lambda
return () => (cond ? cb() : undefined);
}
const setState = (arg: number) => {
'use no memo';
return arg;
};
export const FIXTURE_ENTRYPOINT = {
fn: createHookWrapper(useMakeCallback),
params: [{obj: {value: 1}, cond: true, setState}],
sequentialRenders: [
{obj: {value: 1}, cond: true, setState},
{obj: {value: 2}, cond: true, setState},
],
};
Domain
Subdomains
Functions
Dependencies
- shared-runtime
Source
Frequently Asked Questions
What does function-with-conditional-callsite-in-another-function.ts do?
function-with-conditional-callsite-in-another-function.ts is a source file in the react codebase, written in typescript. It belongs to the TestingUtilities domain, Fixtures subdomain.
What functions are defined in function-with-conditional-callsite-in-another-function.ts?
function-with-conditional-callsite-in-another-function.ts defines 2 function(s): setState, useMakeCallback.
What does function-with-conditional-callsite-in-another-function.ts depend on?
function-with-conditional-callsite-in-another-function.ts imports 1 module(s): shared-runtime.
Where is function-with-conditional-callsite-in-another-function.ts in the architecture?
function-with-conditional-callsite-in-another-function.ts is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/assume-invoked/function-with-conditional-callsite-in-another-function.ts (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/assume-invoked).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free