mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Repro for uninitialized value due to shadowed function name
This commit is contained in:
1 parent
a6b3adbe68
commit
1b6afa1879
2 files changed
+40
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function Component(props) {
|
||||
function hasErrors() {
|
||||
let hasErrors = false;
|
||||
if (props.items == null) {
|
||||
hasErrors = true;
|
||||
}
|
||||
return hasErrors;
|
||||
}
|
||||
return hasErrors();
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
7 | return hasErrors;
|
||||
8 | }
|
||||
> 9 | return hasErrors();
|
||||
| ^^^^^^^^^ [ReactForget] Invariant: [hoisting] Expected value for identifier to be initialized. hasErrors_0$16 (9:9)
|
||||
10 | }
|
||||
11 |
|
||||
```
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
function Component(props) {
|
||||
function hasErrors() {
|
||||
let hasErrors = false;
|
||||
if (props.items == null) {
|
||||
hasErrors = true;
|
||||
}
|
||||
return hasErrors;
|
||||
}
|
||||
return hasErrors();
|
||||
}
|
||||
Reference in new issue
Block a user