-
-
Notifications
You must be signed in to change notification settings - Fork 75
perf: introduce React Compiler to improve performance #720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: introduce React Compiler to improve performance #720
Conversation
✅ Deploy Preview for hi-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for new-eslint ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for es-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for zh-hans-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for pt-br-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for ja-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for de-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for fr-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
| options: { | ||
| configFile: path.resolve(__dirname, ".babelrc"), | ||
| plugins: ["babel-plugin-react-compiler"], | ||
| presets: ["@babel/preset-env", "@babel/preset-react"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ordering: babel-plugin-react-compiler => @babel/preset-react => @babel/preset-env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also is it possible to get some performance metrics before/after this change?
ed7b705 to
bd8cbd3
Compare
|
Hello, @snitin315 After introducing the React Compiler, I observed that some components are now automatically memoized. This helps prevent unnecessary re-renders, which can lead to performance benefits in certain scenarios. However, since render patterns vary across components, it's difficult to provide quantitative measurements. I’d appreciate it if you could consider this change from the perspective of structural optimization. I’d also like to recommend the following article, which provides a good overview of performance differences before and after adopting the React Compiler: Before: Memoization ❌After: Memoization ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!




Prerequisites checklist
What is the purpose of this pull request?
What changes did you make? (Give an overview)
Hello,
This PR introduces the React Compiler, which improves performance through memoization, similar to how we use
useMemo,useCallback, andReact.memo.This PR consists of three parts:
First: Bump the React version to
v19.1.0, the latest version.As mentioned in the official React documentation, the React Compiler works best with React v19. Therefore, I bumped
react,react-dom, andreact-selectorto support the latest React version.Second: Install
babel-plugin-react-compilerto properly support the React Compiler.Here is the guide for using
babel-plugin-react-compiler: https://react.dev/learn/react-compiler#usage-with-babel.I've removed the
.babelrcfile and integrated the configuration directly intowebpack.config.js, sincebabel-plugin-react-compilerneeds to be applied first.Babel processes code in the following order:
https://babeljs.io/docs/plugins#plugin-ordering
Third: Introduce
eslint-plugin-react-hooks@6to properly check the immutability characteristics in React.Alert.jsandConfiguration.jswere modified to enforce immutability. The behavior of the code remains the same; I only added immutability.Related Issues
Is there anything you'd like reviewers to focus on?