mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Update ValidatePreservedManualMemoization severity to
CannotPreserveMemoization We do need to fix the error location to point to the "callsite" rather than the definition of the useMemo callback, but that aside, even if the error message were perfect, it's not meant to be actionable to the user. So let's change the severity to CannotPreserveMemoization. This preserves the validation, but the eslint plugin won't report it. ghstack-source-id: 722c88922884de05e89030a7b001bd93e0a2a114 Pull Request resolved: https://github.com/facebook/react-forget/pull/2825
This commit is contained in:
+1
-1
@@ -439,7 +439,7 @@ class Visitor extends ReactiveFunctionVisitor<VisitorState> {
|
||||
reason:
|
||||
"This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized",
|
||||
description: null,
|
||||
severity: ErrorSeverity.InvalidReact,
|
||||
severity: ErrorSeverity.CannotPreserveMemoization,
|
||||
loc: typeof instruction.loc !== "symbol" ? instruction.loc : null,
|
||||
suggestions: null,
|
||||
});
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
9 | const a = useHook();
|
||||
10 | // Because b is also part of that same mutable range, it can't be memoized either
|
||||
> 11 | const b = useMemo(() => ({}), []);
|
||||
| ^^^^^^^^^^ InvalidReact: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (11:11)
|
||||
| ^^^^^^^^^^ CannotPreserveMemoization: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (11:11)
|
||||
12 |
|
||||
13 | // Conditional assignment without a subsequent mutation normally doesn't create a mutable
|
||||
14 | // range, but in this case we're reassigning a context variable
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
> 10 | ref.current.inner = event.target.value;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
> 11 | });
|
||||
| ^^^^ InvalidReact: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (7:11)
|
||||
| ^^^^ CannotPreserveMemoization: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (7:11)
|
||||
12 |
|
||||
13 | // The ref is modified later, extending its range and preventing memoization of onChange
|
||||
14 | const reset = () => {
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
> 10 | ref.current.inner = event.target.value;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
> 11 | });
|
||||
| ^^^^ InvalidReact: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (7:11)
|
||||
| ^^^^ CannotPreserveMemoization: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (7:11)
|
||||
12 |
|
||||
13 | // The ref is modified later, extending its range and preventing memoization of onChange
|
||||
14 | ref.current.inner = null;
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
> 13 | return identity(val);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
> 14 | }, [val]);
|
||||
| ^^^^ InvalidReact: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (12:14)
|
||||
| ^^^^ CannotPreserveMemoization: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (12:14)
|
||||
15 | }
|
||||
16 |
|
||||
17 | export const FIXTURE_ENTRYPOINT = {
|
||||
|
||||
+2
-2
@@ -33,9 +33,9 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
10 |
|
||||
11 | // makeArray() is captured, but depsList contains [props]
|
||||
> 12 | const cb = useCallback(() => [x], [x]);
|
||||
| ^^^^^^^^^ InvalidReact: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (12:12)
|
||||
| ^^^^^^^^^ CannotPreserveMemoization: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (12:12)
|
||||
|
||||
InvalidReact: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (12:12)
|
||||
CannotPreserveMemoization: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (12:12)
|
||||
13 |
|
||||
14 | x = makeArray();
|
||||
15 |
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
11 | x.push(props);
|
||||
12 |
|
||||
> 13 | return useCallback(() => [x], [x]);
|
||||
| ^^^^^^^^^ InvalidReact: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (13:13)
|
||||
| ^^^^^^^^^ CannotPreserveMemoization: This value was manually memoized, but cannot be memoized under Forget because it may be mutated after it is memoized (13:13)
|
||||
14 | }
|
||||
15 |
|
||||
16 | export const FIXTURE_ENTRYPOINT = {
|
||||
|
||||
Reference in New Issue
Block a user