You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you have more confidence with rolling out the compiler, you can expand coverage to other directories as well and slowly roll it out to your whole app.
186
186
187
+
### Using React Compiler with React 17 or 18 {/*using-react-compiler-with-react-17-or-18*/}
188
+
189
+
React Compiler works best with React 19 RC. If you are unable to upgrade, you can install the extra `react-compiler-runtime` package which will allow the compiled code to run on versions prior to 19. However, note that the minimum supported version is 17.
190
+
191
+
<TerminalBlock>
192
+
npm install react-compiler-runtime@experimental
193
+
</TerminalBlock>
194
+
195
+
You should also add the correct `target` to your compiler config, where `target` is the major version of React you are targeting:
If you're starting a new project, you can enable the compiler on your entire codebase, which is the default behavior.
@@ -369,16 +394,6 @@ To report issues, please first create a minimal repro on the [React Compiler Pla
369
394
370
395
You can also provide feedback in the React Compiler Working Group by applying to be a member. Please see [the README for more details on joining](https://github.com/reactwg/react-compiler).
371
396
372
-
### What does the compiler assume? {/*what-does-the-compiler-assume*/}
373
-
374
-
React Compiler assumes that your code:
375
-
376
-
1. Is valid, semantic JavaScript.
377
-
2. Tests that nullable/optional values and properties are defined before accessing them (for example, by enabling [`strictNullChecks`](https://www.typescriptlang.org/tsconfig/#strictNullChecks) if using TypeScript), i.e., `if (object.nullableProperty) { object.nullableProperty.foo }` or with optional-chaining `object.nullableProperty?.foo`.
378
-
3. Follows the [Rules of React](https://react.dev/reference/rules).
379
-
380
-
React Compiler can verify many of the Rules of React statically, and will safely skip compilation when it detects an error. To see the errors we recommend also installing [eslint-plugin-react-compiler](https://www.npmjs.com/package/eslint-plugin-react-compiler).
381
-
382
397
### How do I know my components have been optimized? {/*how-do-i-know-my-components-have-been-optimized*/}
383
398
384
399
[React Devtools](/learn/react-developer-tools) (v5.0+) has built-in support for React Compiler and will display a "Memo ✨" badge next to components that have been optimized by the compiler.
0 commit comments