mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[repro] bug repro
ghstack-source-id: 64d3266bf39ce5b1b9e9b9470910e029f0e951eb Pull Request resolved: https://github.com/facebook/react-forget/pull/2849
This commit is contained in:
+97
@@ -0,0 +1,97 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
import {
|
||||
CONST_TRUE,
|
||||
identity,
|
||||
makeObject_Primitives,
|
||||
useNoAlias,
|
||||
} from "shared-runtime";
|
||||
/**
|
||||
* BUG
|
||||
* Found differences in evaluator results
|
||||
* Non-forget (expected):
|
||||
* (kind: ok) [{"a":0,"b":"value1","c":true},"[[ cyclic ref *1 ]]"]
|
||||
* [{"a":0,"b":"value1","c":true},"[[ cyclic ref *1 ]]"]
|
||||
* Forget:
|
||||
* (kind: ok) [{"a":0,"b":"value1","c":true},"[[ cyclic ref *1 ]]"]
|
||||
* [[ (exception in render) Error: Oh no! ]]
|
||||
*/
|
||||
|
||||
function Foo() {
|
||||
const obj = makeObject_Primitives();
|
||||
// hook calls keeps the next two lines as its own reactive scope
|
||||
useNoAlias();
|
||||
|
||||
const shouldCaptureObj = obj != null && CONST_TRUE;
|
||||
const result = [shouldCaptureObj ? identity(obj) : null, obj];
|
||||
|
||||
useNoAlias(result, obj);
|
||||
|
||||
if (shouldCaptureObj && result[0] !== obj) {
|
||||
throw new Error("Unexpected");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Foo,
|
||||
params: [{}],
|
||||
sequentialRenders: [{}, {}],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import {
|
||||
CONST_TRUE,
|
||||
identity,
|
||||
makeObject_Primitives,
|
||||
useNoAlias,
|
||||
} from "shared-runtime";
|
||||
/**
|
||||
* BUG
|
||||
* Found differences in evaluator results
|
||||
* Non-forget (expected):
|
||||
* (kind: ok) [{"a":0,"b":"value1","c":true},"[[ cyclic ref *1 ]]"]
|
||||
* [{"a":0,"b":"value1","c":true},"[[ cyclic ref *1 ]]"]
|
||||
* Forget:
|
||||
* (kind: ok) [{"a":0,"b":"value1","c":true},"[[ cyclic ref *1 ]]"]
|
||||
* [[ (exception in render) Error: Oh no! ]]
|
||||
*/
|
||||
|
||||
function Foo() {
|
||||
const $ = useMemoCache(1);
|
||||
const obj = makeObject_Primitives();
|
||||
|
||||
useNoAlias();
|
||||
|
||||
const shouldCaptureObj = obj != null && CONST_TRUE;
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = [shouldCaptureObj ? identity(obj) : null, obj];
|
||||
$[0] = t0;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
}
|
||||
const result = t0;
|
||||
|
||||
useNoAlias(result, obj);
|
||||
if (shouldCaptureObj && result[0] !== obj) {
|
||||
throw new Error("Unexpected");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Foo,
|
||||
params: [{}],
|
||||
sequentialRenders: [{}, {}],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
import {
|
||||
CONST_TRUE,
|
||||
identity,
|
||||
makeObject_Primitives,
|
||||
useNoAlias,
|
||||
} from "shared-runtime";
|
||||
/**
|
||||
* BUG
|
||||
* Found differences in evaluator results
|
||||
* Non-forget (expected):
|
||||
* (kind: ok) [{"a":0,"b":"value1","c":true},"[[ cyclic ref *1 ]]"]
|
||||
* [{"a":0,"b":"value1","c":true},"[[ cyclic ref *1 ]]"]
|
||||
* Forget:
|
||||
* (kind: ok) [{"a":0,"b":"value1","c":true},"[[ cyclic ref *1 ]]"]
|
||||
* [[ (exception in render) Error: Oh no! ]]
|
||||
*/
|
||||
|
||||
function Foo() {
|
||||
const obj = makeObject_Primitives();
|
||||
// hook calls keeps the next two lines as its own reactive scope
|
||||
useNoAlias();
|
||||
|
||||
const shouldCaptureObj = obj != null && CONST_TRUE;
|
||||
const result = [shouldCaptureObj ? identity(obj) : null, obj];
|
||||
|
||||
useNoAlias(result, obj);
|
||||
|
||||
if (shouldCaptureObj && result[0] !== obj) {
|
||||
throw new Error("Unexpected");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Foo,
|
||||
params: [{}],
|
||||
sequentialRenders: [{}, {}],
|
||||
};
|
||||
@@ -488,8 +488,7 @@ const skipFilter = new Set([
|
||||
"rules-of-hooks/rules-of-hooks-69521d94fa03",
|
||||
|
||||
// bugs
|
||||
"bug-reduce-reactive-deps-return-in-scope",
|
||||
"bug-reduce-reactive-deps-break-in-scope",
|
||||
"bug-invalid-reactivity-value-block",
|
||||
|
||||
// 'react-forget-runtime' not yet supported
|
||||
"flag-enable-emit-hook-guards",
|
||||
|
||||
Reference in New Issue
Block a user