Apply compiler and hook lint diagnostics
Choose a compilation scope deliberately
React Compiler can be integrated into a supported build pipeline, for example through babel-plugin-react-compiler. Configure the plugin according to the selected build tool and run it before transformations that obscure the source it analyzes. Do not assume every Vite plugin release has the same integration options. The following is a partial Babel configuration, not a complete build. The infer mode uses heuristics to identify components and Hooks; annotation uses explicit opt-in; all attempts functions at the module level subject to compiler constraints; syntax is intended for Flow component and Hook syntax. An attempted function may still be skipped. Use the target that matches the React runtime. React 19 has the required runtime support; targets 17 and 18 require the separately compatible react-compiler-runtime package.
module.exports={ plugins:[['babel-plugin-react-compiler',{ target:'19', compilationMode:'annotation', panicThreshold:'none' }]]};This configuration selects an explicit trial rather than immediately enabling optimization throughout an application. The documented default error threshold allows skipped optimization rather than failing the entire build for compiler diagnostics. It does not suppress unrelated build errors. A stricter diagnostic configuration can be useful in development. Pin reviewed versions, inspect the integration and use a separate test build. The configuration itself produces no UI.
Opt in or temporarily exclude a function
import React from 'react';export function TileCount({tiles}){ 'use memo'; return <p>{tiles.length} tiles</p>;}export function LegacyBadge({label}){ 'use no memo'; return <span>{label}</span>;}Place each directive in the function prologue before other statements. The first requests compilation under annotation mode; the second excludes its function even when otherwise selected. Neither directive is a Hook or a browser API. They are not the same as the module-level RSC directives. A skipped function is not necessarily incorrect; investigate the reason. Exclusion is a temporary rollout tool, not permission to ignore the Rules of React.
Fix the cause rather than hide the diagnostic
import React from 'react';export function BrokenTiles({tiles}){ tiles.sort((a,b)=>a.name.localeCompare(b.name)); return <ul>{tiles.map(tile=><li key={tile.id}>{tile.name}</li>)}</ul>;}The component sorts its prop array in place. This can change what a sibling sees and invalidate reasoning about identity. A correct alternative is to sort a shallow copy, such as [...tiles].sort(compareNames), then render that copy. The corrected code remains valid whether or not the optimizer runs. Use eslint-plugin-react-hooks with the recommended compiler-aware rules for the installed version. Review immutability, purity, exhaustive-deps and preserve-manual-memoization findings. Fix missing dependencies by restructuring the effect or including the actual reactive values, not by deleting the warning. The compiler cannot catch every possible problem, and a successful JSX transform is not lint or compiler evidence. Practice: find the mutation, rewrite it and describe a migration gate for the annotated candidate.