React has announced its, currently experimental, React Compiler.
Try it out
You can now try this out in your redwood project by running:
yarn rw exp setup-react-compiler
After this you should be able to continue as you would normally using dev or build & serve. If you inspect your pages with the react dev tools you should hopefully see where the compiler has performed auto memoisation.
This command will install both the eslint and babel plugin packages. It will also enable a flag in your toml file:
[experimental.reactCompiler]
enabled = true
lintOnly = false
If you set enabled = false
then this will disable the compiler integration. If you have lintOnly = true
then this will disable the compiler integration but keep the associated linting rules active.
Prerequisites
This setup command is currently available in canary versions of redwood but will be released in our next stable release which is forthcoming.
Your project itself must:
- Be using Vite.
- Be using at least version 19 of React (currently in beta).
- You will have this version if you have enabled the streaming-ssr or RSC experimental features.
Note
This is an experimental feature from React and will not always work perfectly. You can tell us here but also please keep in mind that you might want to inform the React team as they will appreciate all feedback on their new product.