mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Repro for uninitialized value due to shadowed function name
This commit is contained in:
+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