Input
import {useCallback} from 'react';
import {makeArray} from 'shared-runtime';
function Foo(props) {
let x = [];
x.push(props);
const cb = useCallback(() => [x], [x]);
x = makeArray();
return cb;
}
export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [{}],
};
Error
10 |
11 | // makeArray() is captured, but depsList contains [props]
> 12 | const cb = useCallback(() => [x], [x]);
| ^ CannotPreserveMemoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly (12:12)
CannotPreserveMemoization: React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output. (12:12)
13 |
14 | x = makeArray();
15 |