[hoisting] Add more repros for hoisting bugs

This commit is contained in:
Lauren Tan
2023-11-02 11:01:29 -04:00
parent dca54c8932
commit 4a793bb86e
4 changed files with 70 additions and 0 deletions
@@ -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)
```
@@ -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>;
}
@@ -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)
```
@@ -0,0 +1,9 @@
function Component() {
useRunOnceDuringRender(() => {
const handler = () => {
return () => {
detachHandler(handler);
};
};
});
}