Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,19 @@ function collectNonNullsInBlocks(
innerHoistableMap.get(innerFn.func.body.entry),
);
for (const entry of innerHoistables.assumedNonNullObjects) {
assumedNonNullObjects.add(entry);
/**
* Inner functions (e.g. JSX attribute callbacks) prove
* non-nullness at invocation time, but NOT at the outer
* render scope where cache keys are evaluated. Only
* promote an inner hoistable when its root identifier
* is already proven non-null in the outer scope.
*/
const rootNode = context.registry.roots.get(
entry.fullPath.identifier.id,
);
if (rootNode != null && assumedNonNullObjects.has(rootNode)) {
assumedNonNullObjects.add(entry);
}
}
}
} else if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ function component(t0) {
}
const poke = t1;
let t2;
if ($[2] !== mutator.user) {
if ($[2] !== mutator) {
t2 = () => {
mutator.user.hide();
};
$[2] = mutator.user;
$[2] = mutator;
$[3] = t2;
} else {
t2 = $[3];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,19 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a) {
const $ = _c(4);
const $ = _c(2);
let t0;
if ($[0] !== a) {
t0 = { a };
const z = { a };
t0 = function () {
console.log(z.a);
};
$[0] = a;
$[1] = t0;
} else {
t0 = $[1];
}
const z = t0;
let t1;
if ($[2] !== z.a) {
t1 = function () {
console.log(z.a);
};
$[2] = z.a;
$[3] = t1;
} else {
t1 = $[3];
}
const x = t1;
const x = t0;

return x;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,21 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a) {
const $ = _c(4);
const $ = _c(2);
let t0;
if ($[0] !== a) {
t0 = { a: { a } };
$[0] = a;
$[1] = t0;
} else {
t0 = $[1];
}
const z = t0;
let t1;
if ($[2] !== z.a.a) {
t1 = function () {
const z = { a: { a } };
t0 = function () {
(function () {
console.log(z.a.a);
})();
};
$[2] = z.a.a;
$[3] = t1;
$[0] = a;
$[1] = t0;
} else {
t1 = $[3];
t0 = $[1];
}
const x = t1;
const x = t0;

return x;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,19 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
import { c as _c } from "react/compiler-runtime";
function component(a) {
const $ = _c(4);
const $ = _c(2);
let t0;
if ($[0] !== a) {
t0 = { a: { a } };
const z = { a: { a } };
t0 = function () {
console.log(z.a.a);
};
$[0] = a;
$[1] = t0;
} else {
t0 = $[1];
}
const z = t0;
let t1;
if ($[2] !== z.a.a) {
t1 = function () {
console.log(z.a.a);
};
$[2] = z.a.a;
$[3] = t1;
} else {
t1 = $[3];
}
const x = t1;
const x = t0;

return x;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ function Component(props) {
}
const urls = t5;
let t6;
if ($[6] !== comments.length) {
if ($[6] !== comments) {
t6 = (e) => {
if (!comments.length) {
return;
}
console.log(comments.length);
};
$[6] = comments.length;
$[6] = comments;
$[7] = t6;
} else {
t6 = $[7];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ function Component(props) {
const allUrls = [];
const { media, comments, urls } = post;
let t1;
if ($[2] !== comments.length) {
if ($[2] !== comments) {
t1 = (e) => {
if (!comments.length) {
return;
}
console.log(comments.length);
};
$[2] = comments.length;
$[2] = comments;
$[3] = t1;
} else {
t1 = $[3];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Found 1 error:

Compilation Skipped: Existing memoization could not be preserved

React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `Ref.current`, but the source dependencies were []. Inferred dependency not present in source.
React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `Ref`, but the source dependencies were []. Inferred dependency not present in source.

error.ref-like-name-not-Ref.ts:11:30
9 | const Ref = useCustomRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Found 1 error:

Compilation Skipped: Existing memoization could not be preserved

React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `notaref.current`, but the source dependencies were []. Inferred dependency not present in source.
React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. The inferred dependency was `notaref`, but the source dependencies were []. Inferred dependency not present in source.

error.ref-like-name-not-a-ref.ts:11:30
9 | const notaref = useCustomRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ function Foo(t0) {
}
const x = t1;
let t2;
if ($[2] !== x.inner) {
if ($[2] !== x) {
t2 = () => x.inner;
$[2] = x.inner;
$[2] = x;
$[3] = t2;
} else {
t2 = $[3];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function useFoo(t0) {
const $ = _c(13);
const { arr1, arr2 } = t0;
let t1;
if ($[0] !== arr1[0]) {
if ($[0] !== arr1) {
t1 = (e) => arr1[0].value + e.value;
$[0] = arr1[0];
$[0] = arr1;
$[1] = t1;
} else {
t1 = $[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@ function Component(t0) {
const $ = _c(7);
const { a, b } = t0;
let t1;
if ($[0] !== a.value) {
if ($[0] !== a) {
t1 = () => {
console.log(a.value);
};
$[0] = a.value;
$[0] = a;
$[1] = t1;
} else {
t1 = $[1];
}
const logA = t1;
let t2;
if ($[2] !== b.value) {
if ($[2] !== b) {
t2 = () => {
console.log(b.value);
};
$[2] = b.value;
$[2] = b;
$[3] = t2;
} else {
t2 = $[3];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ function useMakeCallback(t0) {
const { obj } = t0;
const [state, setState] = useState(0);
let t1;
if ($[0] !== obj.value) {
if ($[0] !== obj) {
t1 = () => {
if (obj.value !== 0) {
setState(obj.value);
}
};
$[0] = obj.value;
$[0] = obj;
$[1] = t1;
} else {
t1 = $[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ function useMakeCallback(t0) {
const $ = _c(3);
const { obj, shouldMakeCb, setState } = t0;
let t1;
if ($[0] !== obj.value || $[1] !== setState) {
if ($[0] !== obj || $[1] !== setState) {
t1 = () => setState(obj.value);
$[0] = obj.value;
$[0] = obj;
$[1] = setState;
$[2] = t1;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ function useMakeCallback(t0) {
const { obj } = t0;
const [state, setState] = useState(0);
let t1;
if ($[0] !== obj.value || $[1] !== state) {
if ($[0] !== obj || $[1] !== state) {
t1 = () => {
if (obj.value !== state) {
setState(obj.value);
}
};
$[0] = obj.value;
$[0] = obj;
$[1] = state;
$[2] = t1;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ function useMakeCallback(t0) {
const $ = _c(6);
const { obj, cond, setState } = t0;
let t1;
if ($[0] !== obj.value || $[1] !== setState) {
if ($[0] !== obj || $[1] !== setState) {
t1 = () => setState(obj.value);
$[0] = obj.value;
$[0] = obj;
$[1] = setState;
$[2] = t1;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ function useMakeCallback(t0) {
const $ = _c(3);
const { obj, setState } = t0;
let t1;
if ($[0] !== obj.value || $[1] !== setState) {
if ($[0] !== obj || $[1] !== setState) {
t1 = () => setState(obj.value);
$[0] = obj.value;
$[0] = obj;
$[1] = setState;
$[2] = t1;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ function useMakeCallback(t0) {
const $ = _c(3);
const { obj, setState } = t0;
let t1;
if ($[0] !== obj.value || $[1] !== setState) {
if ($[0] !== obj || $[1] !== setState) {
t1 = <Stringify cb={() => setState(obj.value)} shouldInvokeFns={true} />;
$[0] = obj.value;
$[0] = obj;
$[1] = setState;
$[2] = t1;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ function useMakeCallback(t0) {
const $ = _c(3);
const { obj, setState } = t0;
let t1;
if ($[0] !== obj.value || $[1] !== setState) {
if ($[0] !== obj || $[1] !== setState) {
t1 = () => setState(obj.value);
$[0] = obj.value;
$[0] = obj;
$[1] = setState;
$[2] = t1;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function useFoo(t0) {
const $ = _c(5);
const { arr1, arr2 } = t0;
let t1;
if ($[0] !== arr2[0].value) {
if ($[0] !== arr2) {
t1 = (e) => arr2[0].value + e.value;
$[0] = arr2[0].value;
$[0] = arr2;
$[1] = t1;
} else {
t1 = $[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ function useFoo(t0) {
const $ = _c(13);
const { arr1, arr2 } = t0;
let t1;
if ($[0] !== arr1[0]) {
if ($[0] !== arr1) {
t1 = (e) => arr1[0].value + e.value;
$[0] = arr1[0];
$[0] = arr1;
$[1] = t1;
} else {
t1 = $[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ function useMakeCallback(t0) {
const { obj } = t0;
const [state, setState] = useState(0);
let t1;
if ($[0] !== obj.value || $[1] !== state) {
if ($[0] !== obj || $[1] !== state) {
t1 = () => {
if (obj.value !== state) {
setState(obj.value);
}
};
$[0] = obj.value;
$[0] = obj;
$[1] = state;
$[2] = t1;
} else {
Expand Down
Loading
Loading