@samitouri / QOS-React / commits / 4082b0e7d3

[compiler] Detect known incompatible libraries (#34027)

A few libraries are known to be incompatible with memoization, whether manually via `useMemo()` or via React Compiler. This puts us in a tricky situation. On the one hand, we understand that these libraries were developed prior to our documenting the [Rules of React](https://react.dev/reference/rules), and their designs were the result of trying to deliver a great experience for their users and balance multiple priorities around DX, performance, etc. At the same time, using these libraries with memoization — and in particular with automatic memoization via React Compiler — can break apps by causing the components using these APIs not to update. Concretely, the APIs have in common that they return a function which returns different values over time, but where the function itself does not change. Memoizing the result on the identity of the function will mean that the value never changes. Developers reasonable interpret this as "React Compiler broke my code". Of course, the best solution is to work with developers of these libraries to address the root cause, and we're doing that. We've previously discussed this situation with both of the respective libraries: * React Hook Form: https://github.com/react-hook-form/react-hook-form/issues/11910#issuecomment-2135608761 * TanStack Table: https://github.com/facebook/react/issues/33057#issuecomment-2840600158 and https://github.com/TanStack/table/issues/5567 In the meantime we need to make sure that React Compiler can work out of the box as much as possible. This means teaching it about popular libraries that cannot be memoized. We also can't silently skip compilation, as this confuses users, so we need these error messages to be visible to users. To that end, this PR adds: * A flag to mark functions/hooks as incompatible * Validation against use of such functions * A default type provider to provide declarations for two known-incompatible libraries Note that Mobx is also incompatible, but the `observable()` function is called outside of the component itself, so the compiler cannot currently detect it. We may add validation for such APIs in the future. Again, we really empathize with the developers of these libraries. We've tried to word the error message non-judgementally, because we get that it's hard! We're open to feedback about the error message, please let us know.

Joseph Savona committed Aug 28, 2025 at 16:21 UTC 4082b0e7d3c042d49ef8987547b923051936956f
52 files changed +364 -55
compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts
+24 -2
@@ -36,6 +36,14 @@ export enum ErrorSeverity {
36 * memoization.
37 */
38 CannotPreserveMemoization = 'CannotPreserveMemoization',
39 + /**
40 + * An API that is known to be incompatible with the compiler. Generally as a result of
41 + * the library using "interior mutability", ie having a value whose referential identity
42 + * stays the same but which provides access to values that can change. For example a
43 + * function that doesn't change but returns different results, or an object that doesn't
44 + * change identity but whose properties change.
45 + */
46 + IncompatibleLibrary = 'IncompatibleLibrary',
47 /**
48 * Unhandled syntax that we don't support yet.
49 */
@@ -458,7 +466,8 @@ export class CompilerError extends Error {
466 case ErrorSeverity.InvalidJS:
467 case ErrorSeverity.InvalidReact:
468 case ErrorSeverity.InvalidConfig:
461 - case ErrorSeverity.UnsupportedJS: {
469 + case ErrorSeverity.UnsupportedJS:
470 + case ErrorSeverity.IncompatibleLibrary: {
471 return true;
472 }
473 case ErrorSeverity.CannotPreserveMemoization:
@@ -506,8 +515,9 @@ function printErrorSummary(severity: ErrorSeverity, message: string): string {
515 severityCategory = 'Error';
516 break;
517 }
518 + case ErrorSeverity.IncompatibleLibrary:
519 case ErrorSeverity.CannotPreserveMemoization: {
510 - severityCategory = 'Memoization';
520 + severityCategory = 'Compilation Skipped';
521 break;
522 }
523 case ErrorSeverity.Invariant: {
@@ -547,6 +557,9 @@ export enum ErrorCategory {
557 // Checks that manual memoization is preserved
558 PreserveManualMemo = 'PreserveManualMemo',
559
560 + // Checks for known incompatible libraries
561 + IncompatibleLibrary = 'IncompatibleLibrary',
562 +
563 // Checking for no mutations of props, hook arguments, hook return values
564 Immutability = 'Immutability',
565
@@ -870,6 +883,15 @@ function getRuleForCategoryImpl(category: ErrorCategory): LintRule {
883 recommended: true,
884 };
885 }
886 + case ErrorCategory.IncompatibleLibrary: {
887 + return {
888 + category,
889 + name: 'incompatible-library',
890 + description:
891 + 'Validates against usage of libraries which are incompatible with memoization (manual or automatic)',
892 + recommended: true,
893 + };
894 + }
895 default: {
896 assertExhaustive(category, `Unsupported category ${category}`);
897 }
compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts new
+91
@@ -0,0 +1,91 @@
1 +/**
2 + * Copyright (c) Meta Platforms, Inc. and affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +
8 +import {Effect, ValueKind} from '..';
9 +import {TypeConfig} from './TypeSchema';
10 +
11 +/**
12 + * Libraries developed before we officially documented the [Rules of React](https://react.dev/reference/rules)
13 + * implement APIs which cannot be memoized safely, either via manual or automatic memoization.
14 + *
15 + * Any non-hook API that is designed to be called during render (not events/effects) should be safe to memoize:
16 + *
17 + * ```js
18 + * function Component() {
19 + * const {someFunction} = useLibrary();
20 + * // it should always be safe to memoize functions like this
21 + * const result = useMemo(() => someFunction(), [someFunction]);
22 + * }
23 + * ```
24 + *
25 + * However, some APIs implement "interior mutability" — mutating values rather than copying into a new value
26 + * and setting state with the new value. Such functions (`someFunction()` in the example) could return different
27 + * values even though the function itself is the same object. This breaks memoization, since React relies on
28 + * the outer object (or function) changing if part of its value has changed.
29 + *
30 + * Given that we didn't have the Rules of React precisely documented prior to the introduction of React compiler,
31 + * it's understandable that some libraries accidentally shipped APIs that break this rule. However, developers
32 + * can easily run into pitfalls with these APIs. They may manually memoize them, which can break their app. Or
33 + * they may try using React Compiler, and think that the compiler has broken their code.
34 + *
35 + * To help ensure that developers can successfully use the compiler with existing code, this file teaches the
36 + * compiler about specific APIs that are known to be incompatible with memoization. We've tried to be as precise
37 + * as possible.
38 + *
39 + * The React team is open to collaborating with library authors to help develop compatible versions of these APIs,
40 + * and we have already reached out to the teams who own any API listed here to ensure they are aware of the issue.
41 + */
42 +export function defaultModuleTypeProvider(
43 + moduleName: string,
44 +): TypeConfig | null {
45 + switch (moduleName) {
46 + case 'react-hook-form': {
47 + return {
48 + kind: 'object',
49 + properties: {
50 + useForm: {
51 + kind: 'hook',
52 + returnType: {
53 + kind: 'object',
54 + properties: {
55 + // Only the `watch()` function returned by react-hook-form's `useForm()` API is incompatible
56 + watch: {
57 + kind: 'function',
58 + positionalParams: [],
59 + restParam: Effect.Read,
60 + calleeEffect: Effect.Read,
61 + returnType: {kind: 'type', name: 'Any'},
62 + returnValueKind: ValueKind.Mutable,
63 + knownIncompatible: `React Hook Form's \`useForm()\` API returns a \`watch()\` function which cannot be memoized safely.`,
64 + },
65 + },
66 + },
67 + },
68 + },
69 + };
70 + }
71 + case '@tanstack/react-table': {
72 + return {
73 + kind: 'object',
74 + properties: {
75 + /*
76 + * Many of the properties of `useReactTable()`'s return value are incompatible, so we mark the entire hook
77 + * as incompatible
78 + */
79 + useReactTable: {
80 + kind: 'hook',
81 + positionalParams: [],
82 + restParam: Effect.Read,
83 + returnType: {kind: 'type', name: 'Any'},
84 + knownIncompatible: `TanStack Table's \`useReactTable()\` API returns functions that cannot be memoized safely`,
85 + },
86 + },
87 + };
88 + }
89 + }
90 + return null;
91 +}
compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts
+9 -2
@@ -50,6 +50,7 @@ import {
50 import {Scope as BabelScope, NodePath} from '@babel/traverse';
51 import {TypeSchema} from './TypeSchema';
52 import {FlowTypeEnv} from '../Flood/Types';
53 +import {defaultModuleTypeProvider} from './DefaultModuleTypeProvider';
54
55 export const ReactElementSymbolSchema = z.object({
56 elementSymbol: z.union([
@@ -860,10 +861,16 @@ export class Environment {
861 #resolveModuleType(moduleName: string, loc: SourceLocation): Global | null {
862 let moduleType = this.#moduleTypes.get(moduleName);
863 if (moduleType === undefined) {
863 - if (this.config.moduleTypeProvider == null) {
864 + /*
865 + * NOTE: Zod doesn't work when specifying a function as a default, so we have to
866 + * fallback to the default value here
867 + */
868 + const moduleTypeProvider =
869 + this.config.moduleTypeProvider ?? defaultModuleTypeProvider;
870 + if (moduleTypeProvider == null) {
871 return null;
872 }
866 - const unparsedModuleConfig = this.config.moduleTypeProvider(moduleName);
873 + const unparsedModuleConfig = moduleTypeProvider(moduleName);
874 if (unparsedModuleConfig != null) {
875 const parsedModuleConfig = TypeSchema.safeParse(unparsedModuleConfig);
876 if (!parsedModuleConfig.success) {
compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts
+2
@@ -1001,6 +1001,7 @@ export function installTypeConfig(
1001 mutableOnlyIfOperandsAreMutable:
1002 typeConfig.mutableOnlyIfOperandsAreMutable === true,
1003 aliasing: typeConfig.aliasing,
1004 + knownIncompatible: typeConfig.knownIncompatible ?? null,
1005 });
1006 }
1007 case 'hook': {
@@ -1019,6 +1020,7 @@ export function installTypeConfig(
1020 returnValueKind: typeConfig.returnValueKind ?? ValueKind.Frozen,
1021 noAlias: typeConfig.noAlias === true,
1022 aliasing: typeConfig.aliasing,
1023 + knownIncompatible: typeConfig.knownIncompatible ?? null,
1024 });
1025 }
1026 case 'object': {
compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts
+1
@@ -332,6 +332,7 @@ export type FunctionSignature = {
332 mutableOnlyIfOperandsAreMutable?: boolean;
333
334 impure?: boolean;
335 + knownIncompatible?: string | null | undefined;
336
337 canonicalName?: string;
338
compiler/packages/babel-plugin-react-compiler/src/HIR/TypeSchema.ts
+4
@@ -251,6 +251,7 @@ export type FunctionTypeConfig = {
251 impure?: boolean | null | undefined;
252 canonicalName?: string | null | undefined;
253 aliasing?: AliasingSignatureConfig | null | undefined;
254 + knownIncompatible?: string | null | undefined;
255 };
256 export const FunctionTypeSchema: z.ZodType<FunctionTypeConfig> = z.object({
257 kind: z.literal('function'),
@@ -264,6 +265,7 @@ export const FunctionTypeSchema: z.ZodType<FunctionTypeConfig> = z.object({
265 impure: z.boolean().nullable().optional(),
266 canonicalName: z.string().nullable().optional(),
267 aliasing: AliasingSignatureSchema.nullable().optional(),
268 + knownIncompatible: z.string().nullable().optional(),
269 });
270
271 export type HookTypeConfig = {
@@ -274,6 +276,7 @@ export type HookTypeConfig = {
276 returnValueKind?: ValueKind | null | undefined;
277 noAlias?: boolean | null | undefined;
278 aliasing?: AliasingSignatureConfig | null | undefined;
279 + knownIncompatible?: string | null | undefined;
280 };
281 export const HookTypeSchema: z.ZodType<HookTypeConfig> = z.object({
282 kind: z.literal('hook'),
@@ -283,6 +286,7 @@ export const HookTypeSchema: z.ZodType<HookTypeConfig> = z.object({
286 returnValueKind: ValueKindSchema.nullable().optional(),
287 noAlias: z.boolean().nullable().optional(),
288 aliasing: AliasingSignatureSchema.nullable().optional(),
289 + knownIncompatible: z.string().nullable().optional(),
290 });
291
292 export type BuiltInTypeConfig =
compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts
+21
@@ -2170,6 +2170,27 @@ function computeEffectsForLegacySignature(
2170 }),
2171 });
2172 }
2173 + if (signature.knownIncompatible != null && state.env.isInferredMemoEnabled) {
2174 + const errors = new CompilerError();
2175 + errors.pushDiagnostic(
2176 + CompilerDiagnostic.create({
2177 + category: ErrorCategory.IncompatibleLibrary,
2178 + severity: ErrorSeverity.IncompatibleLibrary,
2179 + reason: 'Use of incompatible library',
2180 + description: [
2181 + 'This API returns functions which cannot be memoized without leading to stale UI. ' +
2182 + 'To prevent this, by default React Compiler will skip memoizing this component/hook. ' +
2183 + 'However, you may see issues if values from this API are passed to other components/hooks that are ' +
2184 + 'memoized.',
2185 + ].join(''),
2186 + }).withDetail({
2187 + kind: 'error',
2188 + loc: receiver.loc,
2189 + message: signature.knownIncompatible,
2190 + }),
2191 + );
2192 + throw errors;
2193 + }
2194 const stores: Array<Place> = [];
2195 const captures: Array<Place> = [];
2196 function visit(place: Place, effect: Effect): void {
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidatePreservedManualMemoization.ts
+3 -6
@@ -284,8 +284,7 @@ function validateInferredDep(
284 CompilerDiagnostic.create({
285 category: ErrorCategory.PreserveManualMemo,
286 severity: ErrorSeverity.CannotPreserveMemoization,
287 - reason:
288 - 'Compilation skipped because existing memoization could not be preserved',
287 + reason: 'Existing memoization could not be preserved',
288 description: [
289 'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. ',
290 'The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected. ',
@@ -539,8 +538,7 @@ class Visitor extends ReactiveFunctionVisitor<VisitorState> {
538 CompilerDiagnostic.create({
539 category: ErrorCategory.PreserveManualMemo,
540 severity: ErrorSeverity.CannotPreserveMemoization,
542 - reason:
543 - 'Compilation skipped because existing memoization could not be preserved',
541 + reason: 'Existing memoization could not be preserved',
542 description: [
543 'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. ',
544 'This dependency may be mutated later, which could cause the value to change unexpectedly.',
@@ -588,8 +586,7 @@ class Visitor extends ReactiveFunctionVisitor<VisitorState> {
586 CompilerDiagnostic.create({
587 category: ErrorCategory.PreserveManualMemo,
588 severity: ErrorSeverity.CannotPreserveMemoization,
591 - reason:
592 - 'Compilation skipped because existing memoization could not be preserved',
589 + reason: 'Existing memoization could not be preserved',
590 description: [
591 '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. ',
592 DEBUG
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.hoist-optional-member-expression-with-conditional-optional.expect.md
+1 -1
@@ -26,7 +26,7 @@ function Component(props) {
26 ```
27 Found 1 error:
28
29 -Memoization: Compilation skipped because existing memoization could not be preserved
29 +Compilation Skipped: Existing memoization could not be preserved
30
31 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 `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
32
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.hoist-optional-member-expression-with-conditional.expect.md
+1 -1
@@ -26,7 +26,7 @@ function Component(props) {
26 ```
27 Found 1 error:
28
29 -Memoization: Compilation skipped because existing memoization could not be preserved
29 +Compilation Skipped: Existing memoization could not be preserved
30
31 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 `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
32
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-known-incompatible-function.expect.md new
+34
@@ -0,0 +1,34 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +import {knownIncompatible} from 'ReactCompilerKnownIncompatibleTest';
6 +
7 +function Component() {
8 + const data = knownIncompatible();
9 + return <div>Error</div>;
10 +}
11 +
12 +```
13 +
14 +
15 +## Error
16 +
17 +```
18 +Found 1 error:
19 +
20 +Compilation Skipped: Use of incompatible library
21 +
22 +This API returns functions which cannot be memoized without leading to stale UI. To prevent this, by default React Compiler will skip memoizing this component/hook. However, you may see issues if values from this API are passed to other components/hooks that are memoized.
23 +
24 +error.invalid-known-incompatible-function.ts:4:15
25 + 2 |
26 + 3 | function Component() {
27 +> 4 | const data = knownIncompatible();
28 + | ^^^^^^^^^^^^^^^^^ useKnownIncompatible is known to be incompatible
29 + 5 | return <div>Error</div>;
30 + 6 | }
31 + 7 |
32 +```
33 +
34 +
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-known-incompatible-function.js new
+6
@@ -0,0 +1,6 @@
1 +import {knownIncompatible} from 'ReactCompilerKnownIncompatibleTest';
2 +
3 +function Component() {
4 + const data = knownIncompatible();
5 + return <div>Error</div>;
6 +}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-known-incompatible-hook-return-property.expect.md new
+33
@@ -0,0 +1,33 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +import {useKnownIncompatibleIndirect} from 'ReactCompilerKnownIncompatibleTest';
6 +
7 +function Component() {
8 + const {incompatible} = useKnownIncompatibleIndirect();
9 + return <div>{incompatible()}</div>;
10 +}
11 +
12 +```
13 +
14 +
15 +## Error
16 +
17 +```
18 +Found 1 error:
19 +
20 +Compilation Skipped: Use of incompatible library
21 +
22 +This API returns functions which cannot be memoized without leading to stale UI. To prevent this, by default React Compiler will skip memoizing this component/hook. However, you may see issues if values from this API are passed to other components/hooks that are memoized.
23 +
24 +error.invalid-known-incompatible-hook-return-property.ts:5:15
25 + 3 | function Component() {
26 + 4 | const {incompatible} = useKnownIncompatibleIndirect();
27 +> 5 | return <div>{incompatible()}</div>;
28 + | ^^^^^^^^^^^^ useKnownIncompatibleIndirect returns an incompatible() function that is known incompatible
29 + 6 | }
30 + 7 |
31 +```
32 +
33 +
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-known-incompatible-hook-return-property.js new
+6
@@ -0,0 +1,6 @@
1 +import {useKnownIncompatibleIndirect} from 'ReactCompilerKnownIncompatibleTest';
2 +
3 +function Component() {
4 + const {incompatible} = useKnownIncompatibleIndirect();
5 + return <div>{incompatible()}</div>;
6 +}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-known-incompatible-hook.expect.md new
+34
@@ -0,0 +1,34 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +import {useKnownIncompatible} from 'ReactCompilerKnownIncompatibleTest';
6 +
7 +function Component() {
8 + const data = useKnownIncompatible();
9 + return <div>Error</div>;
10 +}
11 +
12 +```
13 +
14 +
15 +## Error
16 +
17 +```
18 +Found 1 error:
19 +
20 +Compilation Skipped: Use of incompatible library
21 +
22 +This API returns functions which cannot be memoized without leading to stale UI. To prevent this, by default React Compiler will skip memoizing this component/hook. However, you may see issues if values from this API are passed to other components/hooks that are memoized.
23 +
24 +error.invalid-known-incompatible-hook.ts:4:15
25 + 2 |
26 + 3 | function Component() {
27 +> 4 | const data = useKnownIncompatible();
28 + | ^^^^^^^^^^^^^^^^^^^^ useKnownIncompatible is known to be incompatible
29 + 5 | return <div>Error</div>;
30 + 6 | }
31 + 7 |
32 +```
33 +
34 +
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-known-incompatible-hook.js new
+6
@@ -0,0 +1,6 @@
1 +import {useKnownIncompatible} from 'ReactCompilerKnownIncompatibleTest';
2 +
3 +function Component() {
4 + const data = useKnownIncompatible();
5 + return <div>Error</div>;
6 +}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-optional-member-expression-as-memo-dep-non-optional-in-body.expect.md
+1 -1
@@ -20,7 +20,7 @@ function Component(props) {
20 ```
21 Found 1 error:
22
23 -Memoization: Compilation skipped because existing memoization could not be preserved
23 +Compilation Skipped: Existing memoization could not be preserved
24
25 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 `props.items.edges.nodes`, but the source dependencies were [props.items?.edges?.nodes]. Inferred different dependency than source.
26
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-useEffect-dep-not-memoized-bc-range-overlaps-hook.expect.md
+1 -1
@@ -25,7 +25,7 @@ function Component(props) {
25 ```
26 Found 1 error:
27
28 -Memoization: React Compiler has skipped optimizing this component because the effect dependencies could not be memoized. Unmemoized effect dependencies can trigger an infinite loop or other unexpected behavior
28 +Compilation Skipped: React Compiler has skipped optimizing this component because the effect dependencies could not be memoized. Unmemoized effect dependencies can trigger an infinite loop or other unexpected behavior
29
30 error.invalid-useEffect-dep-not-memoized-bc-range-overlaps-hook.ts:9:2
31 7 |
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-useEffect-dep-not-memoized.expect.md
+1 -1
@@ -22,7 +22,7 @@ function Component(props) {
22 ```
23 Found 1 error:
24
25 -Memoization: React Compiler has skipped optimizing this component because the effect dependencies could not be memoized. Unmemoized effect dependencies can trigger an infinite loop or other unexpected behavior
25 +Compilation Skipped: React Compiler has skipped optimizing this component because the effect dependencies could not be memoized. Unmemoized effect dependencies can trigger an infinite loop or other unexpected behavior
26
27 error.invalid-useEffect-dep-not-memoized.ts:6:2
28 4 | function Component(props) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-useInsertionEffect-dep-not-memoized.expect.md
+1 -1
@@ -22,7 +22,7 @@ function Component(props) {
22 ```
23 Found 1 error:
24
25 -Memoization: React Compiler has skipped optimizing this component because the effect dependencies could not be memoized. Unmemoized effect dependencies can trigger an infinite loop or other unexpected behavior
25 +Compilation Skipped: React Compiler has skipped optimizing this component because the effect dependencies could not be memoized. Unmemoized effect dependencies can trigger an infinite loop or other unexpected behavior
26
27 error.invalid-useInsertionEffect-dep-not-memoized.ts:6:2
28 4 | function Component(props) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-useLayoutEffect-dep-not-memoized.expect.md
+1 -1
@@ -22,7 +22,7 @@ function Component(props) {
22 ```
23 Found 1 error:
24
25 -Memoization: React Compiler has skipped optimizing this component because the effect dependencies could not be memoized. Unmemoized effect dependencies can trigger an infinite loop or other unexpected behavior
25 +Compilation Skipped: React Compiler has skipped optimizing this component because the effect dependencies could not be memoized. Unmemoized effect dependencies can trigger an infinite loop or other unexpected behavior
26
27 error.invalid-useLayoutEffect-dep-not-memoized.ts:6:2
28 4 | function Component(props) {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.ref-like-name-not-Ref.expect.md
+1 -1
@@ -33,7 +33,7 @@ export const FIXTURE_ENTRYPOINT = {
33 ```
34 Found 1 error:
35
36 -Memoization: Compilation skipped because existing memoization could not be preserved
36 +Compilation Skipped: Existing memoization could not be preserved
37
38 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.
39
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.ref-like-name-not-a-ref.expect.md
+1 -1
@@ -33,7 +33,7 @@ export const FIXTURE_ENTRYPOINT = {
33 ```
34 Found 1 error:
35
36 -Memoization: Compilation skipped because existing memoization could not be preserved
36 +Compilation Skipped: Existing memoization could not be preserved
37
38 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.
39
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-repro-missed-memoization-from-capture-in-invoked-function-inferred-as-mutation.expect.md
+1 -1
@@ -44,7 +44,7 @@ component Component() {
44 ```
45 Found 1 error:
46
47 -Memoization: Compilation skipped because existing memoization could not be preserved
47 +Compilation Skipped: Existing memoization could not be preserved
48
49 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.
50
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-repro-missed-memoization-from-inferred-mutation-in-logger.expect.md
+3 -3
@@ -54,7 +54,7 @@ component Component(id) {
54 ```
55 Found 3 errors:
56
57 -Memoization: Compilation skipped because existing memoization could not be preserved
57 +Compilation Skipped: Existing memoization could not be preserved
58
59 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.
60
@@ -76,7 +76,7 @@ React Compiler has skipped optimizing this component because the existing manual
76 18 | const setCurrentIndex = useCallback(
77 19 | (index: number) => {
78
79 -Memoization: Compilation skipped because existing memoization could not be preserved
79 +Compilation Skipped: Existing memoization could not be preserved
80
81 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.
82
@@ -88,7 +88,7 @@ React Compiler has skipped optimizing this component because the existing manual
88 30 |
89 31 | if (prevId !== id) {
90
91 -Memoization: Compilation skipped because existing memoization could not be preserved
91 +Compilation Skipped: Existing memoization could not be preserved
92
93 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.
94
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-repro-unmemoized-callback-captured-in-context-variable.expect.md
+1 -1
@@ -52,7 +52,7 @@ export const FIXTURE_ENTRYPOINT = {
52 ```
53 Found 1 error:
54
55 -Memoization: Compilation skipped because existing memoization could not be preserved
55 +Compilation Skipped: Existing memoization could not be preserved
56
57 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.
58
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.validate-memoized-effect-deps-invalidated-dep-value.expect.md
+1 -1
@@ -30,7 +30,7 @@ export const FIXTURE_ENTRYPOINT = {
30 ```
31 Found 1 error:
32
33 -Memoization: React Compiler has skipped optimizing this component because the effect dependencies could not be memoized. Unmemoized effect dependencies can trigger an infinite loop or other unexpected behavior
33 +Compilation Skipped: React Compiler has skipped optimizing this component because the effect dependencies could not be memoized. Unmemoized effect dependencies can trigger an infinite loop or other unexpected behavior
34
35 error.validate-memoized-effect-deps-invalidated-dep-value.ts:11:2
36 9 | const y = [x];
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.validate-object-entries-mutation.expect.md
+2 -2
@@ -27,7 +27,7 @@ export const FIXTURE_ENTRYPOINT = {
27 ```
28 Found 2 errors:
29
30 -Memoization: Compilation skipped because existing memoization could not be preserved
30 +Compilation Skipped: Existing memoization could not be preserved
31
32 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.
33
@@ -40,7 +40,7 @@ error.validate-object-entries-mutation.ts:6:57
40 8 | value.updated = true;
41 9 | });
42
43 -Memoization: Compilation skipped because existing memoization could not be preserved
43 +Compilation Skipped: Existing memoization could not be preserved
44
45 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.
46
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.validate-object-values-mutation.expect.md
+2 -2
@@ -27,7 +27,7 @@ export const FIXTURE_ENTRYPOINT = {
27 ```
28 Found 2 errors:
29
30 -Memoization: Compilation skipped because existing memoization could not be preserved
30 +Compilation Skipped: Existing memoization could not be preserved
31
32 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.
33
@@ -40,7 +40,7 @@ error.validate-object-values-mutation.ts:6:55
40 8 | value.updated = true;
41 9 | });
42
43 -Memoization: Compilation skipped because existing memoization could not be preserved
43 +Compilation Skipped: Existing memoization could not be preserved
44
45 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.
46
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating/dynamic-gating-bailout-nopanic.expect.md
+1 -1
@@ -58,7 +58,7 @@ export const FIXTURE_ENTRYPOINT = {
58 ## Logs
59
60 ```
61 -{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":206},"end":{"line":16,"column":1,"index":433},"filename":"dynamic-gating-bailout-nopanic.ts"},"detail":{"options":{"category":"PreserveManualMemo","severity":"CannotPreserveMemoization","reason":"Compilation skipped because existing memoization could not be preserved","description":"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 `value`, but the source dependencies were []. Inferred dependency not present in source.","suggestions":null,"details":[{"kind":"error","loc":{"start":{"line":9,"column":31,"index":288},"end":{"line":9,"column":52,"index":309},"filename":"dynamic-gating-bailout-nopanic.ts"},"message":"Could not preserve existing manual memoization"}]}}}
61 +{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":206},"end":{"line":16,"column":1,"index":433},"filename":"dynamic-gating-bailout-nopanic.ts"},"detail":{"options":{"category":"PreserveManualMemo","severity":"CannotPreserveMemoization","reason":"Existing memoization could not be preserved","description":"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 `value`, but the source dependencies were []. Inferred dependency not present in source.","suggestions":null,"details":[{"kind":"error","loc":{"start":{"line":9,"column":31,"index":288},"end":{"line":9,"column":52,"index":309},"filename":"dynamic-gating-bailout-nopanic.ts"},"message":"Could not preserve existing manual memoization"}]}}}
62 ```
63
64 ### Eval output
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/error.invalid-useCallback-captures-reassigned-context.expect.md
+2 -2
@@ -31,7 +31,7 @@ export const FIXTURE_ENTRYPOINT = {
31 ```
32 Found 2 errors:
33
34 -Memoization: Compilation skipped because existing memoization could not be preserved
34 +Compilation Skipped: Existing memoization could not be preserved
35
36 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.
37
@@ -44,7 +44,7 @@ error.invalid-useCallback-captures-reassigned-context.ts:11:37
44 13 | x = makeArray();
45 14 |
46
47 -Memoization: Compilation skipped because existing memoization could not be preserved
47 +Compilation Skipped: Existing memoization could not be preserved
48
49 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.
50
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.false-positive-useMemo-dropped-infer-always-invalidating.expect.md
+1 -1
@@ -32,7 +32,7 @@ export const FIXTURE_ENTRYPOINT = {
32 ```
33 Found 1 error:
34
35 -Memoization: Compilation skipped because existing memoization could not be preserved
35 +Compilation Skipped: Existing memoization could not be preserved
36
37 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.
38
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.false-positive-useMemo-infer-mutate-deps.expect.md
+1 -1
@@ -31,7 +31,7 @@ export const FIXTURE_ENTRYPOINT = {
31 ```
32 Found 1 error:
33
34 -Memoization: Compilation skipped because existing memoization could not be preserved
34 +Compilation Skipped: Existing memoization could not be preserved
35
36 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.
37
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.false-positive-useMemo-overlap-scopes.expect.md
+1 -1
@@ -42,7 +42,7 @@ export const FIXTURE_ENTRYPOINT = {
42 ```
43 Found 1 error:
44
45 -Memoization: Compilation skipped because existing memoization could not be preserved
45 +Compilation Skipped: Existing memoization could not be preserved
46
47 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.
48
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.hoist-useCallback-conditional-access-own-scope.expect.md
+1 -1
@@ -28,7 +28,7 @@ export const FIXTURE_ENTRYPOINT = {
28 ```
29 Found 1 error:
30
31 -Memoization: Compilation skipped because existing memoization could not be preserved
31 +Compilation Skipped: Existing memoization could not be preserved
32
33 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 `propB`, but the source dependencies were [propA, propB.x.y]. Inferred less specific property than source.
34
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.hoist-useCallback-infer-conditional-value-block.expect.md
+2 -2
@@ -31,7 +31,7 @@ export const FIXTURE_ENTRYPOINT = {
31 ```
32 Found 2 errors:
33
34 -Memoization: Compilation skipped because existing memoization could not be preserved
34 +Compilation Skipped: Existing memoization could not be preserved
35
36 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 `propA`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
37
@@ -60,7 +60,7 @@ error.hoist-useCallback-infer-conditional-value-block.ts:6:21
60 16 |
61 17 | export const FIXTURE_ENTRYPOINT = {
62
63 -Memoization: Compilation skipped because existing memoization could not be preserved
63 +Compilation Skipped: Existing memoization could not be preserved
64
65 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 `propB`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
66
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.invalid-useCallback-captures-reassigned-context.expect.md
+2 -2
@@ -32,7 +32,7 @@ export const FIXTURE_ENTRYPOINT = {
32 ```
33 Found 2 errors:
34
35 -Memoization: Compilation skipped because existing memoization could not be preserved
35 +Compilation Skipped: Existing memoization could not be preserved
36
37 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.
38
@@ -45,7 +45,7 @@ error.invalid-useCallback-captures-reassigned-context.ts:12:37
45 14 | x = makeArray();
46 15 |
47
48 -Memoization: Compilation skipped because existing memoization could not be preserved
48 +Compilation Skipped: Existing memoization could not be preserved
49
50 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.
51
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.preserve-use-memo-ref-missing-reactive.expect.md
+1 -1
@@ -30,7 +30,7 @@ export const FIXTURE_ENTRYPOINT = {
30 ```
31 Found 1 error:
32
33 -Memoization: Compilation skipped because existing memoization could not be preserved
33 +Compilation Skipped: Existing memoization could not be preserved
34
35 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.
36
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.todo-useCallback-captures-invalidating-value.expect.md
+1 -1
@@ -30,7 +30,7 @@ export const FIXTURE_ENTRYPOINT = {
30 ```
31 Found 1 error:
32
33 -Memoization: Compilation skipped because existing memoization could not be preserved
33 +Compilation Skipped: Existing memoization could not be preserved
34
35 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.
36
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useCallback-aliased-var.expect.md
+1 -1
@@ -21,7 +21,7 @@ function useHook(x) {
21 ```
22 Found 1 error:
23
24 -Memoization: Compilation skipped because existing memoization could not be preserved
24 +Compilation Skipped: Existing memoization could not be preserved
25
26 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 `aliasedX`, but the source dependencies were [x, aliasedProp]. Inferred different dependency than source.
27
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useCallback-conditional-access-noAlloc.expect.md
+1 -1
@@ -27,7 +27,7 @@ export const FIXTURE_ENTRYPOINT = {
27 ```
28 Found 1 error:
29
30 -Memoization: Compilation skipped because existing memoization could not be preserved
30 +Compilation Skipped: Existing memoization could not be preserved
31
32 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 `propB?.x.y`, but the source dependencies were [propA, propB.x.y]. Inferred different dependency than source.
33
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useCallback-infer-less-specific-conditional-access.expect.md
+1 -1
@@ -26,7 +26,7 @@ function Component({propA, propB}) {
26 ```
27 Found 1 error:
28
29 -Memoization: Compilation skipped because existing memoization could not be preserved
29 +Compilation Skipped: Existing memoization could not be preserved
30
31 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 `propB`, but the source dependencies were [propA?.a, propB.x.y]. Inferred less specific property than source.
32
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useCallback-property-call-dep.expect.md
+1 -1
@@ -19,7 +19,7 @@ function Component({propA}) {
19 ```
20 Found 1 error:
21
22 -Memoization: Compilation skipped because existing memoization could not be preserved
22 +Compilation Skipped: Existing memoization could not be preserved
23
24 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 `propA`, but the source dependencies were [propA.x]. Inferred less specific property than source.
25
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-aliased-var.expect.md
+1 -1
@@ -21,7 +21,7 @@ function useHook(x) {
21 ```
22 Found 1 error:
23
24 -Memoization: Compilation skipped because existing memoization could not be preserved
24 +Compilation Skipped: Existing memoization could not be preserved
25
26 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 `x`, but the source dependencies were [aliasedX, aliasedProp]. Inferred different dependency than source.
27
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-infer-less-specific-conditional-access.expect.md
+1 -1
@@ -26,7 +26,7 @@ function Component({propA, propB}) {
26 ```
27 Found 1 error:
28
29 -Memoization: Compilation skipped because existing memoization could not be preserved
29 +Compilation Skipped: Existing memoization could not be preserved
30
31 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 `propB`, but the source dependencies were [propA?.a, propB.x.y]. Inferred less specific property than source.
32
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-infer-less-specific-conditional-value-block.expect.md
+2 -2
@@ -26,7 +26,7 @@ function Component({propA, propB}) {
26 ```
27 Found 2 errors:
28
29 -Memoization: Compilation skipped because existing memoization could not be preserved
29 +Compilation Skipped: Existing memoization could not be preserved
30
31 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 `propA`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
32
@@ -54,7 +54,7 @@ error.useMemo-infer-less-specific-conditional-value-block.ts:6:17
54 15 | }
55 16 |
56
57 -Memoization: Compilation skipped because existing memoization could not be preserved
57 +Compilation Skipped: Existing memoization could not be preserved
58
59 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 `propB`, but the source dependencies were [propA.a, propB.x.y]. Inferred less specific property than source.
60
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-property-call-chained-object.expect.md
+1 -1
@@ -21,7 +21,7 @@ function Component({propA}) {
21 ```
22 Found 1 error:
23
24 -Memoization: Compilation skipped because existing memoization could not be preserved
24 +Compilation Skipped: Existing memoization could not be preserved
25
26 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 `propA`, but the source dependencies were [propA.x]. Inferred less specific property than source.
27
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-property-call-dep.expect.md
+1 -1
@@ -19,7 +19,7 @@ function Component({propA}) {
19 ```
20 Found 1 error:
21
22 -Memoization: Compilation skipped because existing memoization could not be preserved
22 +Compilation Skipped: Existing memoization could not be preserved
23
24 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 `propA`, but the source dependencies were [propA.x]. Inferred less specific property than source.
25
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.useMemo-unrelated-mutation-in-depslist.expect.md
+1 -1
@@ -32,7 +32,7 @@ function useFoo(input1) {
32 ```
33 Found 1 error:
34
35 -Memoization: Compilation skipped because existing memoization could not be preserved
35 +Compilation Skipped: Existing memoization could not be preserved
36
37 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 `input1`, but the source dependencies were [y]. Inferred different dependency than source.
38
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/error.todo-optional-member-expression-with-conditional-optional.expect.md
+1 -1
@@ -26,7 +26,7 @@ function Component(props) {
26 ```
27 Found 1 error:
28
29 -Memoization: Compilation skipped because existing memoization could not be preserved
29 +Compilation Skipped: Existing memoization could not be preserved
30
31 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 `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
32
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/error.todo-optional-member-expression-with-conditional.expect.md
+1 -1
@@ -26,7 +26,7 @@ function Component(props) {
26 ```
27 Found 1 error:
28
29 -Memoization: Compilation skipped because existing memoization could not be preserved
29 +Compilation Skipped: Existing memoization could not be preserved
30
31 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 `props.items`, but the source dependencies were [props?.items, props.cond]. Inferred different dependency than source.
32
compiler/packages/snap/src/sprout/shared-runtime-type-provider.ts
+45
@@ -198,6 +198,51 @@ export function makeSharedRuntimeTypeProvider({
198 },
199 },
200 };
201 + } else if (moduleName === 'ReactCompilerKnownIncompatibleTest') {
202 + /**
203 + * Fake module used for testing validation of known incompatible
204 + * API validation
205 + */
206 + return {
207 + kind: 'object',
208 + properties: {
209 + useKnownIncompatible: {
210 + kind: 'hook',
211 + positionalParams: [],
212 + restParam: EffectEnum.Read,
213 + returnType: {kind: 'type', name: 'Any'},
214 + knownIncompatible: `useKnownIncompatible is known to be incompatible`,
215 + },
216 + useKnownIncompatibleIndirect: {
217 + kind: 'hook',
218 + positionalParams: [],
219 + restParam: EffectEnum.Read,
220 + returnType: {
221 + kind: 'object',
222 + properties: {
223 + incompatible: {
224 + kind: 'function',
225 + positionalParams: [],
226 + restParam: EffectEnum.Read,
227 + calleeEffect: EffectEnum.Read,
228 + returnType: {kind: 'type', name: 'Any'},
229 + returnValueKind: ValueKindEnum.Mutable,
230 + knownIncompatible: `useKnownIncompatibleIndirect returns an incompatible() function that is known incompatible`,
231 + },
232 + },
233 + },
234 + },
235 + knownIncompatible: {
236 + kind: 'function',
237 + positionalParams: [],
238 + restParam: EffectEnum.Read,
239 + calleeEffect: EffectEnum.Read,
240 + returnType: {kind: 'type', name: 'Any'},
241 + returnValueKind: ValueKindEnum.Mutable,
242 + knownIncompatible: `useKnownIncompatible is known to be incompatible`,
243 + },
244 + },
245 + };
246 } else if (moduleName === 'ReactCompilerTest') {
247 /**
248 * Fake module used for testing validation that type providers return hook