React
react.dev › learn › react-compiler
React Compiler – React
Learn what React Compiler does and how it automatically optimizes your React application by handling memoization for you, eliminating the need for manual useMemo, useCallback, and React.memo.
npm
npmjs.com › package › react-compiler-runtime
react-compiler-runtime - npm
Runtime for React Compiler. Latest version: 1.0.0, last published: 5 months ago. Start using react-compiler-runtime in your project by running `npm i react-compiler-runtime`. There are 119 other projects in the npm registry using react-compiler-runtime.
» npm install react-compiler-runtime
How to enable React Compiler for React 18 Page Router Application?
Those instructions have us install npm install react-compiler-runtime@latest and then you have to pass a target flag to React Compiler. How do we do that within Next.js? It looks like from Next's React Compiler's docs we don't manually set up the babel-plugin-react-compiler manually, I'm guessing ... More on github.com
Introducing React Compiler – React
One ever present debate in the React community had been whether you should `useMemo`/`useCallback` all non-primitive props or not. I've often taken the position that you should in real world teams because it's too much work to determine exactly when to otherwise , whereas others argue that it's too much runtime overhead (and noise) and not worth it. u/acemarke has a good summary of the arguments . All that to say, I was curious if this compiler is essentially the React team conceding that you _should_ memoize everything. The answer is pretty interesting - the compiler actually memoizes things in a more efficient way than `useMemo` can . So it's almost the best of all worlds: improved rendering performance from memoization, cheaper memoization cost, and none of the noise of `useMemo`s sprinkled everywhere. I think we'll have to wait a bit longer to see if this works out in practice, and I'm not crazy about having to add another layer of transpilation, but if it works well this will be a pretty big win for React projects in general I think. More on reddit.com
Thoughts on the new react compiler?
Still won't change one fundamental difference for me. In React, you write HTML in JavaScript. (This code gets in my way) In Svelte, you write JavaScript in HTML. (This code gets out of my way) More on reddit.com
React compiler - does it eliminate the need to understand most of React's rendering pitfalls?
The compiler introduces a bunch of new pitfalls - it’s now more important than ever to follow React’s rules of hooks , and to avoid reading or writing ref.current during a render . You should install the React Compiler ESLint Plugin today to learn about the obvious problems in your codebase that block compilation. But the linter can’t catch all the Undefined Behavior that the compiler can trigger in your code, and it will never be able to catch everything without solving the Halting Problem. I’ve been trying to enable the compiler for my company’s codebase. The compiler causes a bunch of E2E tests to fail, and there are no error messages or warnings explaining why the E2E tests are suddenly failing. It’s actually unfortunately quite similar to tracking down UB in C or C++ that was triggered by compiling with -O2 or the like. The compiler succeeds, and the code runs without crashing. But the E2E test expects renders and refreshes that are no longer happening, all because we broke one of React’s rules somewhere in our stack. The only way I’ve made progress has been through binary search: my function sources(filename) in my ReactCompilerConfig hashes the filename into an integer, then uses the bits in the integer to determine if the file should be compiled. Then we iterate and recurse based on whether the E2E test succeeds or fails. This lets us find a minimal set of files for which compilation will break the test, making it easier to track the source of UB down. More on reddit.com
Videos
Medium
jherr2020.medium.com › react-compiler-with-react-18-1e39f60ae71a
React Compiler With React 18 - Jack Herrington
May 22, 2024 - What’s happening here is that the React Compiler is optimizing our components using memoization. But it’s not using the traditional React.memo or useMemo or useCallback to do it. Instead it uses a new hook. That hook used to be called useMemoCache, now it’s called c . And the react-compiler-runtime library has that hook in it.
React
react.dev › blog › 2024 › 10 › 21 › react-compiler-beta-release
React Compiler Beta Release – React
October 21, 2024 - React Compiler produces code that depends on runtime APIs added in React 19, but we’ve since added support for the compiler to also work with React 17 and 18. If you are not on React 19 yet, in the Beta release you can now try out React Compiler ...
npm
npmjs.com › package › @transkripid › react-compiler-runtime
@transkripid/react-compiler-runtime - npm
June 2, 2024 - React compiler runtime compat for react
» npm install @transkripid/react-compiler-runtime
Published Jun 02, 2024
Version 18.2.2
Author Transkrip.id
Reddit
reddit.com › r/reactjs › introducing react compiler – react
r/reactjs on Reddit: Introducing React Compiler – React
May 15, 2024 - One ever present debate in the React community had been whether you should `useMemo`/`useCallback` all non-primitive props or not. I've often taken the position that you should in real world teams because it's too much work to determine exactly when to otherwise, whereas others argue that it's too much runtime overhead (and noise) and not worth it. u/acemarke has a good summary of the arguments. All that to say, I was curious if this compiler ...
GitHub
github.com › facebook › react › blob › main › compiler › packages › react-compiler-runtime › src › index.ts
react/compiler/packages/react-compiler-runtime/src/index.ts at main · facebook/react
* This validation throws on unsound inputs at runtime. * * Components should only be invoked through React as React Compiler could memoize · * the call to AnotherComponent, introducing conditional hook calls in its · * compiled output. * ```js · * function Invalid(props) { * const myJsx = AnotherComponent(props); * return <div> { myJsx } </div>; * } * * Hooks must be named as hooks.
Author facebook
React
react.dev › reference › react-compiler › target
target – React
Configures the React version compatibility for the compiled output. ... To verify the correct runtime is being used, note the different import (react/compiler-runtime for builtin, react-compiler-runtime standalone package for 17/18):