Skip to content

Commit c741d2d

Browse files
committed
[compiler] Silence ref-in-render errors in ESLint
We need this for compiler correctness but the false positive rate is a bit too high, let's suppress in ESLint for now. ghstack-source-id: 2d24397 Pull Request resolved: #30843
1 parent fc0df47 commit c741d2d

File tree

26 files changed

+75
-43
lines changed

26 files changed

+75
-43
lines changed

compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export enum ErrorSeverity {
1818
* Code that breaks the rules of React.
1919
*/
2020
InvalidReact = 'InvalidReact',
21+
/**
22+
* Like InvalidReact, but this specific error is still in testing w some false positives
23+
* so we special-case it to suppress in ESLint.
24+
*/
25+
InvalidRefInRender = 'InvalidRefInRender',
2126
/**
2227
* Incorrect configuration of the compiler.
2328
*/
@@ -232,6 +237,7 @@ export class CompilerError extends Error {
232237
case ErrorSeverity.InvalidJS:
233238
case ErrorSeverity.InvalidReact:
234239
case ErrorSeverity.InvalidConfig:
240+
case ErrorSeverity.InvalidRefInRender:
235241
return true;
236242
case ErrorSeverity.CannotPreserveMemoization:
237243
case ErrorSeverity.Todo:

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoRefAccesInRender.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ function validateNoRefAccessInRenderImpl(
246246
// Report a more precise error when calling a local function that accesses a ref
247247
if (state.refAccessingFunctions.has(callee.identifier.id)) {
248248
errors.push({
249-
severity: ErrorSeverity.InvalidReact,
249+
severity: ErrorSeverity.InvalidRefInRender,
250250
reason:
251251
'This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef)',
252252
loc: callee.loc,
@@ -351,7 +351,7 @@ function validateNoRefValueAccess(
351351
state.refAccessingFunctions.has(operand.identifier.id)
352352
) {
353353
errors.push({
354-
severity: ErrorSeverity.InvalidReact,
354+
severity: ErrorSeverity.InvalidRefInRender,
355355
reason:
356356
'Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)',
357357
loc: state.refValues.get(operand.identifier.id) ?? operand.loc,
@@ -377,7 +377,7 @@ function validateNoRefAccess(
377377
state.refAccessingFunctions.has(operand.identifier.id)
378378
) {
379379
errors.push({
380-
severity: ErrorSeverity.InvalidReact,
380+
severity: ErrorSeverity.InvalidRefInRender,
381381
reason:
382382
'Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)',
383383
loc: loc,
@@ -398,7 +398,7 @@ function validateNoDirectRefValueAccess(
398398
): void {
399399
if (state.refValues.has(operand.identifier.id)) {
400400
errors.push({
401-
severity: ErrorSeverity.InvalidReact,
401+
severity: ErrorSeverity.InvalidRefInRender,
402402
reason:
403403
'Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)',
404404
loc: state.refValues.get(operand.identifier.id) ?? operand.loc,

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.capture-ref-for-later-mutation.expect.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ export const FIXTURE_ENTRYPOINT = {
3535
10 | };
3636
11 | const moveLeft = {
3737
> 12 | handler: handleKey('left'),
38-
| ^^^^^^^^^ InvalidReact: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (12:12)
38+
| ^^^^^^^^^ InvalidRefInRender: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (12:12)
3939
40-
InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (12:12)
40+
InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (12:12)
4141
42-
InvalidReact: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (15:15)
42+
InvalidRefInRender: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (15:15)
4343
44-
InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (15:15)
44+
InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (15:15)
4545
13 | };
4646
14 | const moveRight = {
4747
15 | handler: handleKey('right'),

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-access-ref-during-render.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function Component(props) {
1818
2 | function Component(props) {
1919
3 | const ref = useRef(null);
2020
> 4 | const value = ref.current;
21-
| ^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
21+
| ^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
2222
5 | return value;
2323
6 | }
2424
7 |

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-aliased-ref-in-callback-invoked-during-render-.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function Component(props) {
2222
7 | return <Foo item={item} current={current} />;
2323
8 | };
2424
> 9 | return <Items>{props.items.map(item => renderItem(item))}</Items>;
25-
| ^^^^^^^^^^^^^^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (9:9)
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (9:9)
2626
10 | }
2727
11 |
2828
```

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-disallow-mutating-ref-in-render.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Component() {
1919
2 | function Component() {
2020
3 | const ref = useRef(null);
2121
> 4 | ref.current = false;
22-
| ^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
22+
| ^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
2323
5 |
2424
6 | return <button ref={ref} />;
2525
7 | }

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-disallow-mutating-refs-in-render-transitive.expect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ function Component() {
2424
7 | };
2525
8 | const changeRef = setRef;
2626
> 9 | changeRef();
27-
| ^^^^^^^^^ InvalidReact: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (9:9)
27+
| ^^^^^^^^^ InvalidRefInRender: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (9:9)
2828
29-
InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (9:9)
29+
InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (9:9)
3030
10 |
3131
11 | return <button ref={ref} />;
3232
12 | }

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-pass-ref-to-function.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function Component(props) {
1818
2 | function Component(props) {
1919
3 | const ref = useRef(null);
2020
> 4 | const x = foo(ref);
21-
| ^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
21+
| ^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
2222
5 | return x.current;
2323
6 | }
2424
7 |

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-read-ref-prop-in-render-destructure.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Component({ref}) {
1717
1 | // @validateRefAccessDuringRender @compilationMode(infer)
1818
2 | function Component({ref}) {
1919
> 3 | const value = ref.current;
20-
| ^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (3:3)
20+
| ^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (3:3)
2121
4 | return <div>{value}</div>;
2222
5 | }
2323
6 |

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-read-ref-prop-in-render-property-load.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Component(props) {
1717
1 | // @validateRefAccessDuringRender @compilationMode(infer)
1818
2 | function Component(props) {
1919
> 3 | const value = props.ref.current;
20-
| ^^^^^^^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (3:3)
20+
| ^^^^^^^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (3:3)
2121
4 | return <div>{value}</div>;
2222
5 | }
2323
6 |

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-ref-in-callback-invoked-during-render.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function Component(props) {
2121
6 | return <Foo item={item} current={current} />;
2222
7 | };
2323
> 8 | return <Items>{props.items.map(item => renderItem(item))}</Items>;
24-
| ^^^^^^^^^^^^^^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (8:8)
24+
| ^^^^^^^^^^^^^^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (8:8)
2525
9 | }
2626
10 |
2727
```

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-ref-value-as-props.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Component(props) {
1717
2 | function Component(props) {
1818
3 | const ref = useRef(null);
1919
> 4 | return <Foo ref={ref.current} />;
20-
| ^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
20+
| ^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
2121
5 | }
2222
6 |
2323
```

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-set-and-read-ref-during-render.expect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function Component(props) {
1818
2 | function Component(props) {
1919
3 | const ref = useRef(null);
2020
> 4 | ref.current = props.value;
21-
| ^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
21+
| ^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
2222
23-
InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (5:5)
23+
InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (5:5)
2424
5 | return ref.current;
2525
6 | }
2626
7 |

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-set-and-read-ref-nested-property-during-render.expect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function Component(props) {
1818
2 | function Component(props) {
1919
3 | const ref = useRef({inner: null});
2020
> 4 | ref.current.inner = props.value;
21-
| ^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
21+
| ^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
2222
23-
InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (5:5)
23+
InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (5:5)
2424
5 | return ref.current.inner;
2525
6 | }
2626
7 |

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-use-ref-added-to-dep-without-type-info.expect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ function Foo({a}) {
2525
8 | // however, this is an instance of accessing a ref during render and is disallowed
2626
9 | // under React's rules, so we reject this input
2727
> 10 | const x = {a, val: val.ref.current};
28-
| ^^^^^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (10:10)
28+
| ^^^^^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (10:10)
2929
30-
InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (10:10)
30+
InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (10:10)
3131
11 |
3232
12 | return <VideoList videos={x} />;
3333
13 | }

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-write-but-dont-read-ref-in-render.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function useHook({value}) {
2020
3 | const ref = useRef(null);
2121
4 | // Writing to a ref in render is against the rules:
2222
> 5 | ref.current = value;
23-
| ^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (5:5)
23+
| ^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (5:5)
2424
6 | // returning a ref is allowed, so this alone doesn't trigger an error:
2525
7 | return ref;
2626
8 | }

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-write-ref-prop-in-render.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function Component(props) {
1818
2 | function Component(props) {
1919
3 | const ref = props.ref;
2020
> 4 | ref.current = true;
21-
| ^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
21+
| ^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (4:4)
2222
5 | return <div>{value}</div>;
2323
6 | }
2424
7 |

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.repro-ref-mutable-range.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const FIXTURE_ENTRYPOINT = {
3131
9 | mutate(value);
3232
10 | if (CONST_TRUE) {
3333
> 11 | return <Stringify ref={identity(ref)} />;
34-
| ^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (11:11)
34+
| ^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (11:11)
3535
12 | }
3636
13 | return value;
3737
14 | }

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-useCallback-set-ref-nested-property-ref-modified-later-preserve-memoization.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const FIXTURE_ENTRYPOINT = {
3434
12 |
3535
13 | // The ref is modified later, extending its range and preventing memoization of onChange
3636
> 14 | ref.current.inner = null;
37-
| ^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (14:14)
37+
| ^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (14:14)
3838
15 |
3939
16 | return <input onChange={onChange} />;
4040
17 | }

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.useCallback-accesses-ref-mutated-later-via-function-preserve-memoization.expect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export const FIXTURE_ENTRYPOINT = {
3737
15 | ref.current.inner = null;
3838
16 | };
3939
> 17 | reset();
40-
| ^^^^^ InvalidReact: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (17:17)
40+
| ^^^^^ InvalidRefInRender: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (17:17)
4141
42-
InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (17:17)
42+
InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (17:17)
4343
18 |
4444
19 | return <input onChange={onChange} />;
4545
20 | }

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.useCallback-set-ref-nested-property-dont-preserve-memoization.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const FIXTURE_ENTRYPOINT = {
3333
11 | });
3434
12 |
3535
> 13 | ref.current.inner = null;
36-
| ^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (13:13)
36+
| ^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (13:13)
3737
14 |
3838
15 | return <input onChange={onChange} />;
3939
16 | }

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.validate-mutate-ref-arg-in-render.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const FIXTURE_ENTRYPOINT = {
2323
1 | // @validateRefAccessDuringRender:true
2424
2 | function Foo(props, ref) {
2525
> 3 | console.log(ref.current);
26-
| ^^^^^^^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (3:3)
26+
| ^^^^^^^^^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (3:3)
2727
4 | return <div>{props.bar}</div>;
2828
5 | }
2929
6 |

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/original-reactive-scopes-fork/error.capture-ref-for-later-mutation.expect.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ export const FIXTURE_ENTRYPOINT = {
3636
11 | };
3737
12 | const moveLeft = {
3838
> 13 | handler: handleKey('left'),
39-
| ^^^^^^^^^ InvalidReact: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (13:13)
39+
| ^^^^^^^^^ InvalidRefInRender: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (13:13)
4040
41-
InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (13:13)
41+
InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (13:13)
4242
43-
InvalidReact: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (16:16)
43+
InvalidRefInRender: This function accesses a ref value (the `current` property), which may not be accessed during render. (https://react.dev/reference/react/useRef) (16:16)
4444
45-
InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (16:16)
45+
InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (16:16)
4646
14 | };
4747
15 | const moveRight = {
4848
16 | handler: handleKey('right'),

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.maybe-mutable-ref-not-preserved.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const FIXTURE_ENTRYPOINT = {
2626
6 | function useFoo() {
2727
7 | const r = useRef();
2828
> 8 | return useMemo(() => makeArray(r), []);
29-
| ^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (8:8)
29+
| ^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (8:8)
3030
9 | }
3131
10 |
3232
11 | export const FIXTURE_ENTRYPOINT = {

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-with-refs.flow.expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ component Component(disableLocalRef, ref) {
2222
5 | const localRef = useFooRef();
2323
6 | const mergedRef = useMemo(() => {
2424
> 7 | return disableLocalRef ? ref : identity(ref, localRef);
25-
| ^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (7:7)
25+
| ^^^ InvalidRefInRender: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (7:7)
2626
8 | }, [disableLocalRef, ref, localRef]);
2727
9 | return <div ref={mergedRef} />;
2828
10 | }

0 commit comments

Comments
 (0)