Skip to content

Mirror of upstream PR #33113 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
18e4165
[compiler] Repro for false positive ValidateNoFreezingKnownMutableFun…
josephsavona May 3, 2025
0ee6891
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 3, 2025
e7fcefc
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 8, 2025
5a976c6
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 8, 2025
0fd33c4
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 8, 2025
a0f7bca
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 8, 2025
8362c04
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 9, 2025
b2b384a
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 9, 2025
4de20da
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 9, 2025
8da1df5
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 9, 2025
40e29bb
Update base for Update on "[compiler] Repro for false positive Valida…
josephsavona May 9, 2025
646e843
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 9, 2025
878c4c9
Update base for Update on "[compiler] Repro for false positive Valida…
josephsavona May 12, 2025
069eef0
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 12, 2025
f469cd3
Update base for Update on "[compiler] Repro for false positive Valida…
josephsavona May 13, 2025
e4bc838
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 13, 2025
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,58 @@

## Input

```javascript
// @validateNoFreezingKnownMutableFunctions

import {useCallback, useEffect, useRef} from 'react';
import {useHook} from 'shared-runtime';

function Component() {
const params = useHook();
const update = useCallback(
partialParams => {
const nextParams = {
...params,
...partialParams,
};
nextParams.param = 'value';
console.log(nextParams);
},
[params]
);
const ref = useRef(null);
useEffect(() => {
if (ref.current === null) {
update();
}
}, [update]);

return 'ok';
}

```


## Error

```
18 | );
19 | const ref = useRef(null);
> 20 | useEffect(() => {
| ^^^^^^^
> 21 | if (ref.current === null) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 22 | update();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 23 | }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 24 | }, [update]);
| ^^^^ InvalidReact: This argument is a function which modifies local variables when called, which can bypass memoization and cause the UI not to update. Functions that are returned from hooks, passed as arguments to hooks, or passed as props to components may not mutate local variables (20:24)

InvalidReact: The function modifies a local variable here (14:14)
25 |
26 | return 'ok';
27 | }
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// @validateNoFreezingKnownMutableFunctions

import {useCallback, useEffect, useRef} from 'react';
import {useHook} from 'shared-runtime';

function Component() {
const params = useHook();
const update = useCallback(
partialParams => {
const nextParams = {
...params,
...partialParams,
};
nextParams.param = 'value';
console.log(nextParams);
},
[params]
);
const ref = useRef(null);
useEffect(() => {
if (ref.current === null) {
update();
}
}, [update]);

return 'ok';
}
Loading