Commit 9dc1a1b
committed
[compiler]
This enables `@enablePreserveExistingMemoizationGuarantees` by default.
As of the previous PR (#34503), this mode now enables the following
behaviors:
- Treating variables referenced within a `useMemo()` or `useCallback()`
as "frozen" (immutable) as of the start of the call. Ie, the compiler
will assume that the values you reference are not mutated by the body of
the useMemo, not are they mutated later. Directly modifying them (eg
`var.property = true`) will be an error.
- Similarly, the results of the useMemo/useCallback are treated as
frozen (immutable) after the call.
These two rules match the behavior for other hooks: this means that
developers will see similar behavior to swapping out `useMemo()` for a
custom `useMyMemo()` wrapper/alias.
Additionally, as of #34503 the compiler uses information from the manual
dependencies to know which variables are non-nullable. Even if a useMemo
block conditionally accesses a nested property — `if (cond) { log(x.y.z)
}` — where the compiler would not usually know that `x` is non-nullable,
if the user specifies `x.y.z` as a manual dependency then the compiler
knows that `x` and `x.y` are non-nullable and can infer a more precise
dependency.
Finally, this mode also ensures that we always memoize function calls
that return primitives. See #34343 for more details.
For now, I've explicitly opted out of this feature in all test fixtures
where the behavior changed.
DiffTrain build for [70b52be](70b52be)@enablePreserveExistingMemoizationGuarantees on by default (#34689)1 parent def8123 commit 9dc1a1b
File tree
26 files changed
+91
-91
lines changed- compiled-rn
- facebook-fbsource/xplat/js
- RKJSModules/vendor/react
- react-dom/cjs
- react-test-renderer/cjs
- react/cjs
- react-native-github/Libraries/Renderer
- implementations
- tools/eslint-plugin-react-hooks
- cjs
26 files changed
+91
-91
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
408 | 408 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
30061 | 30061 | | |
30062 | 30062 | | |
30063 | 30063 | | |
30064 | | - | |
| 30064 | + | |
30065 | 30065 | | |
30066 | 30066 | | |
30067 | 30067 | | |
30068 | | - | |
| 30068 | + | |
30069 | 30069 | | |
30070 | 30070 | | |
30071 | 30071 | | |
| |||
30102 | 30102 | | |
30103 | 30103 | | |
30104 | 30104 | | |
30105 | | - | |
| 30105 | + | |
30106 | 30106 | | |
30107 | 30107 | | |
30108 | | - | |
| 30108 | + | |
30109 | 30109 | | |
30110 | 30110 | | |
30111 | 30111 | | |
| |||
30255 | 30255 | | |
30256 | 30256 | | |
30257 | 30257 | | |
30258 | | - | |
| 30258 | + | |
30259 | 30259 | | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
17578 | 17578 | | |
17579 | 17579 | | |
17580 | 17580 | | |
17581 | | - | |
| 17581 | + | |
17582 | 17582 | | |
17583 | 17583 | | |
17584 | 17584 | | |
17585 | 17585 | | |
17586 | 17586 | | |
17587 | 17587 | | |
17588 | | - | |
| 17588 | + | |
17589 | 17589 | | |
17590 | 17590 | | |
17591 | 17591 | | |
| |||
17607 | 17607 | | |
17608 | 17608 | | |
17609 | 17609 | | |
17610 | | - | |
| 17610 | + | |
17611 | 17611 | | |
17612 | 17612 | | |
17613 | | - | |
| 17613 | + | |
17614 | 17614 | | |
17615 | 17615 | | |
17616 | 17616 | | |
| |||
17717 | 17717 | | |
17718 | 17718 | | |
17719 | 17719 | | |
17720 | | - | |
| 17720 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
19716 | 19716 | | |
19717 | 19717 | | |
19718 | 19718 | | |
19719 | | - | |
| 19719 | + | |
19720 | 19720 | | |
19721 | 19721 | | |
19722 | 19722 | | |
19723 | 19723 | | |
19724 | 19724 | | |
19725 | 19725 | | |
19726 | | - | |
| 19726 | + | |
19727 | 19727 | | |
19728 | 19728 | | |
19729 | 19729 | | |
| |||
19745 | 19745 | | |
19746 | 19746 | | |
19747 | 19747 | | |
19748 | | - | |
| 19748 | + | |
19749 | 19749 | | |
19750 | 19750 | | |
19751 | | - | |
| 19751 | + | |
19752 | 19752 | | |
19753 | 19753 | | |
19754 | 19754 | | |
| |||
19871 | 19871 | | |
19872 | 19872 | | |
19873 | 19873 | | |
19874 | | - | |
| 19874 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
30117 | 30117 | | |
30118 | 30118 | | |
30119 | 30119 | | |
30120 | | - | |
| 30120 | + | |
30121 | 30121 | | |
30122 | 30122 | | |
30123 | 30123 | | |
30124 | | - | |
| 30124 | + | |
30125 | 30125 | | |
30126 | 30126 | | |
30127 | 30127 | | |
| |||
30158 | 30158 | | |
30159 | 30159 | | |
30160 | 30160 | | |
30161 | | - | |
| 30161 | + | |
30162 | 30162 | | |
30163 | 30163 | | |
30164 | | - | |
| 30164 | + | |
30165 | 30165 | | |
30166 | 30166 | | |
30167 | 30167 | | |
| |||
30627 | 30627 | | |
30628 | 30628 | | |
30629 | 30629 | | |
30630 | | - | |
| 30630 | + | |
30631 | 30631 | | |
30632 | 30632 | | |
30633 | 30633 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
17589 | 17589 | | |
17590 | 17590 | | |
17591 | 17591 | | |
17592 | | - | |
| 17592 | + | |
17593 | 17593 | | |
17594 | 17594 | | |
17595 | 17595 | | |
17596 | 17596 | | |
17597 | 17597 | | |
17598 | 17598 | | |
17599 | | - | |
| 17599 | + | |
17600 | 17600 | | |
17601 | 17601 | | |
17602 | 17602 | | |
| |||
17618 | 17618 | | |
17619 | 17619 | | |
17620 | 17620 | | |
17621 | | - | |
| 17621 | + | |
17622 | 17622 | | |
17623 | 17623 | | |
17624 | | - | |
| 17624 | + | |
17625 | 17625 | | |
17626 | 17626 | | |
17627 | 17627 | | |
| |||
17881 | 17881 | | |
17882 | 17882 | | |
17883 | 17883 | | |
17884 | | - | |
| 17884 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
19731 | 19731 | | |
19732 | 19732 | | |
19733 | 19733 | | |
19734 | | - | |
| 19734 | + | |
19735 | 19735 | | |
19736 | 19736 | | |
19737 | 19737 | | |
19738 | 19738 | | |
19739 | 19739 | | |
19740 | 19740 | | |
19741 | | - | |
| 19741 | + | |
19742 | 19742 | | |
19743 | 19743 | | |
19744 | 19744 | | |
| |||
19760 | 19760 | | |
19761 | 19761 | | |
19762 | 19762 | | |
19763 | | - | |
| 19763 | + | |
19764 | 19764 | | |
19765 | 19765 | | |
19766 | | - | |
| 19766 | + | |
19767 | 19767 | | |
19768 | 19768 | | |
19769 | 19769 | | |
| |||
20039 | 20039 | | |
20040 | 20040 | | |
20041 | 20041 | | |
20042 | | - | |
| 20042 | + | |
20043 | 20043 | | |
20044 | 20044 | | |
20045 | 20045 | | |
| |||
0 commit comments