mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
[compiler][repro] ValidatePreserveMemo x useRef bug
ghstack-source-id: 6ac5d58e97
Pull Request resolved: https://github.com/facebook/react/pull/30602
This commit is contained in:
1 parent
e662b0a24b
commit
2bd415355e
2 files changed
+59
No files matched your search
+45
@@ -0,0 +1,45 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @validatePreserveExistingMemoizationGuarantees:true
|
||||
|
||||
import {useRef, useMemo} from 'react';
|
||||
import {makeArray} from 'shared-runtime';
|
||||
|
||||
function useFoo() {
|
||||
const r = useRef();
|
||||
return useMemo(() => makeArray(r), []);
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: useFoo,
|
||||
params: [],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
// @validatePreserveExistingMemoizationGuarantees:true
|
||||
|
||||
import { useRef, useMemo } from "react";
|
||||
import { makeArray } from "shared-runtime";
|
||||
|
||||
function useFoo() {
|
||||
const r = useRef();
|
||||
let t0;
|
||||
t0 = makeArray(r);
|
||||
return t0;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: useFoo,
|
||||
params: [],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
### Eval output
|
||||
(kind: ok) [{}]
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// @validatePreserveExistingMemoizationGuarantees:true
|
||||
|
||||
import {useRef, useMemo} from 'react';
|
||||
import {makeArray} from 'shared-runtime';
|
||||
|
||||
function useFoo() {
|
||||
const r = useRef();
|
||||
return useMemo(() => makeArray(r), []);
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: useFoo,
|
||||
params: [],
|
||||
};
|
||||
Reference in new issue
Block a user