Skip to content

Commit

Permalink
[snap] Fix misconfigured React and broken tests
Browse files Browse the repository at this point in the history
ghstack-source-id: 8f6451528b4b92e251b83e4e389bea6b697ea3cb
Pull Request resolved: #31078
  • Loading branch information
poteto committed Sep 26, 2024
1 parent b2c53e1 commit b7499c3
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ function Component() {
);
}

function cx(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
const cx = {
foo(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
}
}
}
return classes.join(' ');
}
return classes.join(' ');
},
};

function useTheme() {
return {
Expand Down Expand Up @@ -71,15 +73,17 @@ function Component() {
return t1;
}

function cx(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
const cx = {
foo(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
}
}
}
return classes.join(" ");
}
return classes.join(" ");
},
};

function useTheme() {
return {
Expand All @@ -97,4 +101,4 @@ export const FIXTURE_ENTRYPOINT = {
```
### Eval output
(kind: exception) cx.foo is not a function
(kind: ok) <div class="styles/light styles/dark"></div>
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ function Component() {
);
}

function cx(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
const cx = {
foo(obj) {
const classes = [];
for (const [key, value] of Object.entries(obj)) {
if (value) {
classes.push(key);
}
}
}
return classes.join(' ');
}
return classes.join(' ');
},
};

function useTheme() {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
```javascript
import {CONST_TRUE, identity, shallowCopy} from 'shared-runtime';

function mutate(_: unknown) {}

/**
* There are three values with their own scopes in this fixture.
* - arr, whose mutable range extends to the `mutate(...)` call
Expand Down Expand Up @@ -45,6 +47,8 @@ export const FIXTURE_ENTRYPOINT = {
import { c as _c } from "react/compiler-runtime";
import { CONST_TRUE, identity, shallowCopy } from "shared-runtime";

function mutate(_) {}

/**
* There are three values with their own scopes in this fixture.
* - arr, whose mutable range extends to the `mutate(...)` call
Expand Down Expand Up @@ -91,4 +95,4 @@ export const FIXTURE_ENTRYPOINT = {
```
### Eval output
(kind: exception) mutate is not defined
(kind: ok)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {CONST_TRUE, identity, shallowCopy} from 'shared-runtime';

function mutate(_: unknown) {}

/**
* There are three values with their own scopes in this fixture.
* - arr, whose mutable range extends to the `mutate(...)` call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import {useCallback} from 'react';
import {identity, useIdentity} from 'shared-runtime';

function mutate(_: unknown) {}

/**
* Repro showing a manual memo whose declaration (useCallback's 1st argument)
* is memoized, but not its dependency (x). In this case, `x`'s scope is pruned
Expand Down Expand Up @@ -33,6 +35,8 @@ import { c as _c } from "react/compiler-runtime"; // @validatePreserveExistingMe
import { useCallback } from "react";
import { identity, useIdentity } from "shared-runtime";

function mutate(_) {}

/**
* Repro showing a manual memo whose declaration (useCallback's 1st argument)
* is memoized, but not its dependency (x). In this case, `x`'s scope is pruned
Expand Down Expand Up @@ -62,4 +66,4 @@ export const FIXTURE_ENTRYPOINT = {
```
### Eval output
(kind: exception) mutate is not defined
(kind: ok) "[[ function params=0 ]]"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import {useCallback} from 'react';
import {identity, useIdentity} from 'shared-runtime';

function mutate(_: unknown) {}

/**
* Repro showing a manual memo whose declaration (useCallback's 1st argument)
* is memoized, but not its dependency (x). In this case, `x`'s scope is pruned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
```javascript
import {identity, makeObject_Primitives} from 'shared-runtime';

function useHook() {}

function useTest({cond}) {
const val = makeObject_Primitives();

Expand Down Expand Up @@ -31,6 +33,8 @@ export const FIXTURE_ENTRYPOINT = {
import { c as _c } from "react/compiler-runtime";
import { identity, makeObject_Primitives } from "shared-runtime";

function useHook() {}

function useTest(t0) {
const $ = _c(3);
const { cond } = t0;
Expand Down Expand Up @@ -64,4 +68,4 @@ export const FIXTURE_ENTRYPOINT = {
```
### Eval output
(kind: exception) useHook is not defined
(kind: ok) {"a":0,"b":"value1","c":true}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {identity, makeObject_Primitives} from 'shared-runtime';

function useHook() {}

function useTest({cond}) {
const val = makeObject_Primitives();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Input

```javascript
import {makeObject_Primitives} from 'shared-runtime';
import {makeObject_Primitives, Stringify} from 'shared-runtime';

function Component(props) {
let useFeature = makeObject_Primitives();
Expand Down Expand Up @@ -32,7 +32,7 @@ export const FIXTURE_ENTRYPOINT = {

```javascript
import { c as _c } from "react/compiler-runtime";
import { makeObject_Primitives } from "shared-runtime";
import { makeObject_Primitives, Stringify } from "shared-runtime";

function Component(props) {
const $ = _c(2);
Expand Down Expand Up @@ -75,4 +75,4 @@ export const FIXTURE_ENTRYPOINT = {
```
### Eval output
(kind: exception) Stringify is not defined
(kind: ok) <div>{"val":{"a":0,"b":"value1","c":true},"children":[2,"[[ cyclic ref *1 ]]",null]}</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeObject_Primitives} from 'shared-runtime';
import {makeObject_Primitives, Stringify} from 'shared-runtime';

function Component(props) {
let useFeature = makeObject_Primitives();
Expand Down

0 comments on commit b7499c3

Please sign in to comment.