53 lines
1005 B
Markdown
53 lines
1005 B
Markdown
|
|||
|
|
## Input
|
||
|
|
|
||
|
|
```javascript
|
||
|
|
function Component() {
|
||
|
|
const onClick = () => {
|
||
|
|
// Cannot assign to globals
|
||
|
|
someUnknownGlobal = true;
|
||
|
|
moduleLocal = true;
|
||
|
|
};
|
||
|
|
// It's possible that this could be an event handler / effect function,
|
||
|
|
// but we don't know that and optimistically assume it will only be
|
||
|
|
// called by an event handler or effect, where it is allowed to modify globals
|
||
|
|
return <div onClick={onClick} />;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const FIXTURE_ENTRYPOINT = {
|
||
|
|
fn: Component,
|
||
|
|
params: [{}],
|
||
|
|
};
|
||
|
|
|
||
|
|
```
|
||
|
|
|
||
|
|
## Code
|
||
|
|
|
||
|
|
```javascript
|
||
|
|
import { c as _c } from "react/compiler-runtime";
|
||
|
|
function Component() {
|
||
|
|
const $ = _c(1);
|
||
|
|
const onClick = _temp;
|
||
|
|
let t0;
|
||
|
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||
|
|
t0 = <div onClick={onClick} />;
|
||
|
|
$[0] = t0;
|
||
|
|
} else {
|
||
|
|
t0 = $[0];
|
||
|
|
}
|
||
|
|
return t0;
|
||
|
|
}
|
||
|
|
function _temp() {
|
||
|
|
someUnknownGlobal = true;
|
||
|
|
moduleLocal = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const FIXTURE_ENTRYPOINT = {
|
||
|
|
fn: Component,
|
||
|
|
params: [{}],
|
||
|
|
};
|
||
|
|
|
||
|
|
```
|
||
|
|
|
||
|
|
### Eval output
|
||
|
|
(kind: ok) <div></div>
|