Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

## Input

```javascript
// @flow @validateRefAccessDuringRender @validatePreserveExistingMemoizationGuarantees

component Foo() {
const ref = useRef();

const s = () => {
return ref.current;
};

return s;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [],
};

```


## Error

```
8 | };
9 |
> 10 | return s;
| ^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef). Cannot access ref value at freeze $25:TObject<BuiltInFunction> (10:10)
11 | }
12 |
13 | export const FIXTURE_ENTRYPOINT = {
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// @flow @validateRefAccessDuringRender @validatePreserveExistingMemoizationGuarantees

component Foo() {
const ref = useRef();

const s = () => {
return ref.current;
};

return s;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

## Input

```javascript
// @flow @validateRefAccessDuringRender @validatePreserveExistingMemoizationGuarantees

component Foo() {
const ref = useRef();

const s = useCallback(() => {
return ref.current;
});

return <a r={s} />;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [],
};

```


## Error

```
4 | const ref = useRef();
5 |
> 6 | const s = useCallback(() => {
| ^^^^^^^
> 7 | return ref.current;
| ^^^^^^^^^^^^^^^^^^^^^^^
> 8 | });
| ^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef). Cannot access ref value at read $27:TObject<BuiltInFunction> (6:8)
9 |
10 | return <a r={s} />;
11 | }
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// @flow @validateRefAccessDuringRender @validatePreserveExistingMemoizationGuarantees

component Foo() {
const ref = useRef();

const s = useCallback(() => {
return ref.current;
});

return <a r={s} />;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [],
};