1
+
2
+## Input
3
+
4
+```javascript
5
+//@flow
6
+import {useRef} from 'react';
7
+
8
+component C() {
9
+ const r = useRef(null);
10
+ const current = !r.current;
11
+ return <div>{current}</div>;
12
+}
13
+
14
+export const FIXTURE_ENTRYPOINT = {
15
+ fn: C,
16
+ params: [{}],
17
+};
18
+
19
+```
20
+
21
+
22
+## Error
23
+
24
+```
25
+Found 4 errors:
26
+
27
+Error: Cannot access refs during render
28
+
29
+React refs are values that are not needed for rendering. Refs should only be accessed outside of render, such as in event handlers or effects. Accessing a ref value (the `current` property) during render can cause your component not to update as expected (https://react.dev/reference/react/useRef).
30
+
31
+ 4 | component C() {
32
+ 5 | const r = useRef(null);
33
+> 6 | const current = !r.current;
34
+ | ^^^^^^^^^ Cannot access ref value during render
35
+ 7 | return <div>{current}</div>;
36
+ 8 | }
37
+ 9 |
38
+
39
+To initialize a ref only once, check that the ref is null with the pattern `if (ref.current == null) { ref.current = ... }`
40
+
41
+Error: Cannot access refs during render
42
+
43
+React refs are values that are not needed for rendering. Refs should only be accessed outside of render, such as in event handlers or effects. Accessing a ref value (the `current` property) during render can cause your component not to update as expected (https://react.dev/reference/react/useRef).
44
+
45
+ 4 | component C() {
46
+ 5 | const r = useRef(null);
47
+> 6 | const current = !r.current;
48
+ | ^^^^^^^^^^ Cannot access ref value during render
49
+ 7 | return <div>{current}</div>;
50
+ 8 | }
51
+ 9 |
52
+
53
+Error: Cannot access refs during render
54
+
55
+React refs are values that are not needed for rendering. Refs should only be accessed outside of render, such as in event handlers or effects. Accessing a ref value (the `current` property) during render can cause your component not to update as expected (https://react.dev/reference/react/useRef).
56
+
57
+ 5 | const r = useRef(null);
58
+ 6 | const current = !r.current;
59
+> 7 | return <div>{current}</div>;
60
+ | ^^^^^^^ Cannot access ref value during render
61
+ 8 | }
62
+ 9 |
63
+ 10 | export const FIXTURE_ENTRYPOINT = {
64
+
65
+Error: Cannot access refs during render
66
+
67
+React refs are values that are not needed for rendering. Refs should only be accessed outside of render, such as in event handlers or effects. Accessing a ref value (the `current` property) during render can cause your component not to update as expected (https://react.dev/reference/react/useRef).
68
+
69
+ 5 | const r = useRef(null);
70
+ 6 | const current = !r.current;
71
+> 7 | return <div>{current}</div>;
72
+ | ^^^^^^^ Cannot access ref value during render
73
+ 8 | }
74
+ 9 |
75
+ 10 | export const FIXTURE_ENTRYPOINT = {
76
+```
77
+
78
+
\ No newline at end of file