mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[hoisting] Add more repros for hoisting bugs
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function Component(props) {
|
||||
const wat = () => {
|
||||
const pathname = "wat";
|
||||
pathname;
|
||||
};
|
||||
|
||||
const pathname = props.wat;
|
||||
const deeplinkItemId = pathname ? itemID : null;
|
||||
|
||||
return <button onClick={() => wat()}>{deeplinkItemId}</button>;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] Invariant: Expected value kind to be initialized at '8:25:8:33' (8:8)
|
||||
```
|
||||
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function Component(props) {
|
||||
const wat = () => {
|
||||
const pathname = "wat";
|
||||
pathname;
|
||||
};
|
||||
|
||||
const pathname = props.wat;
|
||||
const deeplinkItemId = pathname ? itemID : null;
|
||||
|
||||
return <button onClick={() => wat()}>{deeplinkItemId}</button>;
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function Component() {
|
||||
useRunOnceDuringRender(() => {
|
||||
const handler = () => {
|
||||
return () => {
|
||||
detachHandler(handler);
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier handler$1 is undefined (3:7)
|
||||
```
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
function Component() {
|
||||
useRunOnceDuringRender(() => {
|
||||
const handler = () => {
|
||||
return () => {
|
||||
detachHandler(handler);
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user