@samitouri / QOS-React-1 / commits / 24ed13e1f0

Update error message and comments

Joe Savona committed Feb 13, 2024 at 16:45 UTC 24ed13e1f04ccc843f559948137405a7191b4b13
2 files changed +17 -1
compiler/packages/babel-plugin-react-forget/src/HIR/ComputeUnconditionalBlocks.ts
+1 -1
@@ -23,7 +23,7 @@ export function computeUnconditionalBlocks(fn: HIRFunction): Set<BlockId> {
23 while (current !== null && current !== exit) {
24 CompilerError.invariant(!unconditionalBlocks.has(current), {
25 reason:
26 - "Internal error: non-terminating loop in ValidateUnconditionalHooks",
26 + "Internal error: non-terminating loop in ComputeUnconditionalBlocks",
27 loc: null,
28 suggestions: null,
29 });
compiler/packages/babel-plugin-react-forget/src/Validation/ValidateNoRefAccesInRender.ts
+16
@@ -23,6 +23,22 @@ import { Err, Ok, Result } from "../Utils/Result";
23 /**
24 * Validates that a function does not access a ref value during render. This includes a partial check
25 * for ref values which are accessed indirectly via function expressions.
26 + *
27 + * ```javascript
28 + * // ERROR
29 + * const ref = useRef();
30 + * ref.current;
31 + *
32 + * const ref = useRef();
33 + * foo(ref); // may access .current
34 + *
35 + * // ALLOWED
36 + * const ref = useHookThatReturnsRef();
37 + * ref.current;
38 + * ```
39 + *
40 + * In the future we may reject more cases, based on either object names (`fooRef.current` is likely a ref)
41 + * or based on property name alone (`foo.current` might be a ref).
42 */
43 export function validateNoRefAccessInRender(fn: HIRFunction): void {
44 const refAccessingFunctions: Set<IdentifierId> = new Set();