-
Notifications
You must be signed in to change notification settings - Fork 46.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler] patch: retain UpdateExpression for globals
ghstack-source-id: aff6606f85698ccda13d1deffb6faa9d91f9821a Pull Request resolved: #30471
- Loading branch information
Showing
7 changed files
with
67 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
.../__tests__/fixtures/compiler/bug-invalid-update-global-should-bailout.expect.md
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
...er/src/__tests__/fixtures/compiler/error.update-global-should-bailout.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
let renderCount = 0; | ||
function useFoo() { | ||
renderCount += 1; | ||
return renderCount; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: useFoo, | ||
params: [], | ||
}; | ||
|
||
``` | ||
|
||
|
||
## Error | ||
|
||
``` | ||
1 | let renderCount = 0; | ||
2 | function useFoo() { | ||
> 3 | renderCount += 1; | ||
| ^^^^^^^^^^^^^^^^ InvalidReact: Unexpected reassignment of a variable which was defined outside of the component. Components and hooks should be pure and side-effect free, but variable reassignment is a form of side-effect. If this variable is used in rendering, use useState instead. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render) (3:3) | ||
4 | return renderCount; | ||
5 | } | ||
6 | | ||
``` | ||
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters