ValidateNoRefAccessInRender.ts — react Source File
Architecture documentation for ValidateNoRefAccessInRender.ts, a typescript file in the react codebase. 17 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 8dbbe52d_b145_88fe_e0da_33d06180b558["ValidateNoRefAccessInRender.ts"] e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> e96f281e_f381_272d_2359_3e6a091c9a1d 0fda7f86_b7a3_c1f2_f0d9_8d13eed4f042["CompilerDiagnostic"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> 0fda7f86_b7a3_c1f2_f0d9_8d13eed4f042 e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> e51fd0d2_bb38_cc97_7763_efe37f300a47 a2b91621_58d3_1d04_4663_00cd808f1034["ErrorCategory"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> a2b91621_58d3_1d04_4663_00cd808f1034 0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> 0423f759_97e0_9101_4634_ed555abc5ca9 58f81300_7c82_5086_3e10_e46b5f3ab04d["ObjectShape.ts"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> 58f81300_7c82_5086_3e10_e46b5f3ab04d 2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> 2f3caf55_cc64_415c_55dd_9771ba7dc210 ccace1c3_85b7_a05e_c2a5_7eff8b3422ed["eachInstructionOperand"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> ccace1c3_85b7_a05e_c2a5_7eff8b3422ed b2fc2985_a7ba_9865_c2a3_2a7531f27d44["eachInstructionValueOperand"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> b2fc2985_a7ba_9865_c2a3_2a7531f27d44 f5637d03_fd91_50b8_9da7_b2a24c91bab7["eachPatternOperand"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> f5637d03_fd91_50b8_9da7_b2a24c91bab7 41232a25_deb6_6e83_05a8_ae9f961656f7["eachTerminalOperand"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> 41232a25_deb6_6e83_05a8_ae9f961656f7 494e3425_0b47_293a_1ea4_d4670b0fc0e7["Result.ts"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> 494e3425_0b47_293a_1ea4_d4670b0fc0e7 9217845a_d29d_c624_b607_e3b35cf604bc["Err"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> 9217845a_d29d_c624_b607_e3b35cf604bc 9f0e6a52_ff9e_00f3_1760_5fddfd89b234["Ok"] 8dbbe52d_b145_88fe_e0da_33d06180b558 --> 9f0e6a52_ff9e_00f3_1760_5fddfd89b234 style 8dbbe52d_b145_88fe_e0da_33d06180b558 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {
CompilerDiagnostic,
CompilerError,
ErrorCategory,
} from '../CompilerError';
import {
BlockId,
GeneratedSource,
HIRFunction,
IdentifierId,
Identifier,
Place,
SourceLocation,
getHookKindForType,
isRefValueType,
isUseRefType,
} from '../HIR';
import {BuiltInEventHandlerId} from '../HIR/ObjectShape';
import {
eachInstructionOperand,
eachInstructionValueOperand,
eachPatternOperand,
eachTerminalOperand,
} from '../HIR/visitors';
import {Err, Ok, Result} from '../Utils/Result';
import {retainWhere} from '../Utils/utils';
/**
* Validates that a function does not access a ref value during render. This includes a partial check
* for ref values which are accessed indirectly via function expressions.
*
* ```javascript
* // ERROR
* const ref = useRef();
* ref.current;
*
* const ref = useRef();
* foo(ref); // may access .current
*
* // ALLOWED
* const ref = useHookThatReturnsRef();
* ref.current;
* ```
*
* In the future we may reject more cases, based on either object names (`fooRef.current` is likely a ref)
* or based on property name alone (`foo.current` might be a ref).
*/
const opaqueRefId = Symbol();
type RefId = number & {[opaqueRefId]: 'RefId'};
function makeRefId(id: number): RefId {
CompilerError.invariant(id >= 0 && Number.isInteger(id), {
// ... (823 more lines)
Domain
Subdomains
Functions
- collectTemporariesSidemap()
- destructure()
- guardCheck()
- isEventHandlerType()
- joinRefAccessTypes()
- makeRefId()
- nextRefId()
- refTypeOfType()
- tyEqual()
- validateNoDirectRefValueAccess()
- validateNoRefAccessInRender()
- validateNoRefAccessInRenderImpl()
- validateNoRefPassedToFunction()
- validateNoRefUpdate()
- validateNoRefValueAccess()
Classes
Dependencies
Source
Frequently Asked Questions
What does ValidateNoRefAccessInRender.ts do?
ValidateNoRefAccessInRender.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ValidateNoRefAccessInRender.ts?
ValidateNoRefAccessInRender.ts defines 15 function(s): collectTemporariesSidemap, destructure, guardCheck, isEventHandlerType, joinRefAccessTypes, makeRefId, nextRefId, refTypeOfType, tyEqual, validateNoDirectRefValueAccess, and 5 more.
What does ValidateNoRefAccessInRender.ts depend on?
ValidateNoRefAccessInRender.ts imports 17 module(s): CompilerDiagnostic, CompilerError, CompilerError.ts, Err, ErrorCategory, ObjectShape.ts, Ok, Result, and 9 more.
Where is ValidateNoRefAccessInRender.ts in the architecture?
ValidateNoRefAccessInRender.ts is located at compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoRefAccessInRender.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/Validation).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free