-
Notifications
You must be signed in to change notification settings - Fork 47.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ghstack-source-id: 5a8395225783df9a2d29892ee39c31af0fc5742c Pull Request resolved: #29834
- Loading branch information
1 parent
a532d91
commit 7bc7dec
Showing
6 changed files
with
74 additions
and
1 deletion.
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
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
25 changes: 25 additions & 0 deletions
25
..._/fixtures/compiler/error.invalid-read-ref-prop-in-render-destructure.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,25 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
// @validateRefAccessDuringRender @compilationMode(infer) | ||
function Component({ ref }) { | ||
const value = ref.current; | ||
return <div>{value}</div>; | ||
} | ||
|
||
``` | ||
|
||
|
||
## Error | ||
|
||
``` | ||
2 | function Component({ ref }) { | ||
3 | const value = ref.current; | ||
> 4 | return <div>{value}</div>; | ||
| ^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef). Cannot access ref value at read $17:TObject<BuiltInRefValue> (4:4) | ||
5 | } | ||
6 | | ||
``` | ||
5 changes: 5 additions & 0 deletions
5
...iler/src/__tests__/fixtures/compiler/error.invalid-read-ref-prop-in-render-destructure.js
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,5 @@ | ||
// @validateRefAccessDuringRender @compilationMode(infer) | ||
function Component({ ref }) { | ||
const value = ref.current; | ||
return <div>{value}</div>; | ||
} |
25 changes: 25 additions & 0 deletions
25
...fixtures/compiler/error.invalid-read-ref-prop-in-render-property-load.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,25 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
// @validateRefAccessDuringRender @compilationMode(infer) | ||
function Component(props) { | ||
const value = props.ref.current; | ||
return <div>{value}</div>; | ||
} | ||
|
||
``` | ||
|
||
|
||
## Error | ||
|
||
``` | ||
2 | function Component(props) { | ||
3 | const value = props.ref.current; | ||
> 4 | return <div>{value}</div>; | ||
| ^^^^^ InvalidReact: Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef). Cannot access ref value at read $15:TObject<BuiltInRefValue> (4:4) | ||
5 | } | ||
6 | | ||
``` | ||
5 changes: 5 additions & 0 deletions
5
...er/src/__tests__/fixtures/compiler/error.invalid-read-ref-prop-in-render-property-load.js
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,5 @@ | ||
// @validateRefAccessDuringRender @compilationMode(infer) | ||
function Component(props) { | ||
const value = props.ref.current; | ||
return <div>{value}</div>; | ||
} |