Skip to content

[compiler] Repro for false positive ValidateNoFreezingKnownMutableFunctions #33113

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

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 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
646e843
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 9, 2025
069eef0
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 12, 2025
e4bc838
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 13, 2025
1f1ab05
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 22, 2025
aabcb05
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 23, 2025
23b4ed8
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 27, 2025
2898de0
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 27, 2025
cae1b29
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 28, 2025
3e31792
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 28, 2025
9be00e6
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 29, 2025
bc38949
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 29, 2025
759260d
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 30, 2025
71780cd
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 30, 2025
2d56d2a
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 30, 2025
180eb1c
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona May 30, 2025
d4d76f4
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 2, 2025
904ff4a
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 3, 2025
0cc8f91
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 3, 2025
a90c22d
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 3, 2025
4559dea
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 4, 2025
4cbf5e5
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 4, 2025
e20721b
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 5, 2025
f5b3f00
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 5, 2025
c33a2f6
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 6, 2025
d881271
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 6, 2025
b6e9707
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 6, 2025
7e2478a
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 6, 2025
e503486
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 7, 2025
92245fb
Update on "[compiler] Repro for false positive ValidateNoFreezingKnow…
josephsavona Jun 9, 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