newUid() — react Function Reference
Architecture documentation for the newUid() function in Imports.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD be5dd024_ebb7_729f_f653_2158dc13ee4c["newUid()"] 1bba49a9_dc32_ad8e_e249_ee6b8eb56d16["ProgramContext"] be5dd024_ebb7_729f_f653_2158dc13ee4c -->|defined in| 1bba49a9_dc32_ad8e_e249_ee6b8eb56d16 7fdb3fec_c4d5_7678_ad85_e8976e3417ad["insertAdditionalFunctionDeclaration()"] 7fdb3fec_c4d5_7678_ad85_e8976e3417ad -->|calls| be5dd024_ebb7_729f_f653_2158dc13ee4c dd08b3af_83bb_70f8_8837_798eff915e39["addImportSpecifier()"] dd08b3af_83bb_70f8_8837_798eff915e39 -->|calls| be5dd024_ebb7_729f_f653_2158dc13ee4c d94198b4_0d10_05c9_4f74_b75616595f53["isHookName()"] be5dd024_ebb7_729f_f653_2158dc13ee4c -->|calls| d94198b4_0d10_05c9_4f74_b75616595f53 b5c63c35_0468_f7d9_414d_79eceec19099["hasReference()"] be5dd024_ebb7_729f_f653_2158dc13ee4c -->|calls| b5c63c35_0468_f7d9_414d_79eceec19099 style be5dd024_ebb7_729f_f653_2158dc13ee4c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Imports.ts lines 130–155
newUid(name: string): string {
/**
* Don't call babel's generateUid for known hook imports, as
* InferTypes might eventually type `HookKind` based on callee naming
* convention and `_useFoo` is not named as a hook.
*
* Local uid generation is susceptible to check-before-use bugs since we're
* checking for naming conflicts / references long before we actually insert
* the import. (see similar logic in HIRBuilder:resolveBinding)
*/
let uid;
if (this.isHookName(name)) {
uid = name;
let i = 0;
while (this.hasReference(uid)) {
this.knownReferencedNames.add(uid);
uid = `${name}_${i++}`;
}
} else if (!this.hasReference(name)) {
uid = name;
} else {
uid = this.scope.generateUid(name);
}
this.knownReferencedNames.add(uid);
return uid;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does newUid() do?
newUid() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Imports.ts.
Where is newUid() defined?
newUid() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Imports.ts at line 130.
What does newUid() call?
newUid() calls 2 function(s): hasReference, isHookName.
What calls newUid()?
newUid() is called by 2 function(s): addImportSpecifier, insertAdditionalFunctionDeclaration.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free