├── .eslintrc.json ├── .gitignore ├── README.md ├── next.config.mjs ├── package-lock.json ├── package.json ├── postcss.config.mjs ├── public ├── file-text.svg ├── globe.svg ├── next.svg ├── vercel.svg └── window.svg ├── src ├── app │ ├── countries-broken │ │ └── page.tsx │ ├── countries-fixed │ │ └── page.tsx │ ├── favicon.ico │ ├── fonts │ │ ├── GeistMonoVF.woff │ │ └── GeistVF.woff │ ├── globals.css │ ├── layout.tsx │ ├── page.tsx │ ├── providers.tsx │ └── simple-cases │ │ └── page.tsx ├── components │ ├── button.tsx │ ├── countries-broken.tsx │ ├── countries-fixed.tsx │ ├── input.tsx │ ├── simple-cases.tsx │ ├── table.tsx │ └── very-slow-component.tsx └── helpers │ ├── cn.ts │ ├── log-on-re-render.ts │ └── resources.ts ├── tailwind.config.ts └── tsconfig.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.* 7 | .yarn/* 8 | !.yarn/patches 9 | !.yarn/plugins 10 | !.yarn/releases 11 | !.yarn/versions 12 | 13 | # testing 14 | /coverage 15 | 16 | # next.js 17 | /.next/ 18 | /out/ 19 | 20 | # production 21 | /build 22 | 23 | # misc 24 | .DS_Store 25 | *.pem 26 | 27 | # debug 28 | npm-debug.log* 29 | yarn-debug.log* 30 | yarn-error.log* 31 | 32 | # env files (can opt-in for commiting if needed) 33 | .env* 34 | 35 | # vercel 36 | .vercel 37 | 38 | # typescript 39 | *.tsbuildinfo 40 | next-env.d.ts 41 | 42 | .idea -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React Compiler test run 2 | 3 | This is a few code examples of the React Compiler working and not working. They are written to illustrate the article [I tried React Compiler today, and guess what... 😉](https://developerway.com/posts/i-tried-react-compiler) 4 | 5 | ## Getting Started 6 | 7 | Install the dependencies: 8 | 9 | ```bash 10 | npm install --force 11 | ``` 12 | 13 | Run the development server: 14 | 15 | ```bash 16 | npm run dev 17 | ``` 18 | 19 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 20 | -------------------------------------------------------------------------------- /next.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | experimental: { 4 | reactCompiler: true 5 | } 6 | }; 7 | 8 | export default nextConfig; 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-compiler-test", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@radix-ui/react-slot": "^1.0.2", 13 | "@tanstack/react-query": "^5.35.1", 14 | "class-variance-authority": "^0.7.0", 15 | "clsx": "^2.1.1", 16 | "next": "15.0.0-canary.1", 17 | "react": "19.0.0-rc-f994737d14-20240522", 18 | "react-dom": "19.0.0-rc-f994737d14-20240522", 19 | "tailwind-merge": "^2.3.0" 20 | }, 21 | "devDependencies": { 22 | "@types/node": "^20", 23 | "@types/react": "^18", 24 | "@types/react-dom": "^18", 25 | "babel-plugin-react-compiler": "^0.0.0-experimental-487cb0e-20240529", 26 | "eslint": "^8", 27 | "eslint-config-next": "15.0.0-canary.1", 28 | "postcss": "^8", 29 | "prettier": "^3.2.5", 30 | "tailwindcss": "^3.4.1", 31 | "typescript": "^5" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /postcss.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('postcss-load-config').Config} */ 2 | const config = { 3 | plugins: { 4 | tailwindcss: {}, 5 | }, 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /public/file-text.svg: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /public/globe.svg: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /public/window.svg: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /src/app/countries-broken/page.tsx: -------------------------------------------------------------------------------- 1 | import { CountriesBroken } from "@/components/countries-broken"; 2 | 3 | export default async function Page() { 4 | return ( 5 |
61 |
31 | Click the button, the dialog will show up with a delay. Slow component 32 | re-render will be visible in the console. 33 |
34 | 35 | {isOpen && } 36 |51 | Click the button, the dialog will show up without the delay. Slow 52 | component re-render will not be visible in the console. 53 |
54 | 55 | {isOpen && } 56 |68 | Click the button, the dialog will show up without the delay. Slow 69 | component re-render will not be visible in the console. 70 |
71 | 72 | {isOpen && } 73 |89 | Click the button, the dialog will show up with a delay. Slow component 90 | re-render will be visible in the console. 91 |
92 | 93 | {isOpen && } 94 |112 | Click the button, the dialog will show up without the delay. Slow 113 | component re-render will not be visible in the console. 114 |
115 | 116 | {isOpen && } 117 |132 | Click the button, the dialog will show up without the delay. Slow 133 | component re-render will not be visible in the console. 134 |
135 | 136 | {isOpen && } 137 |151 | Click the button, the dialog will show up with a delay. Slow component 152 | re-render will be visible in the console. 153 |
154 | 155 | {isOpen && } 156 |175 | Click the button, the dialog will show up without the delay. Slow 176 | component re-render will not be visible in the console. 177 |
178 | 179 | {isOpen && } 180 |192 | Click the button, the dialog will show up without the delay. Slow 193 | component re-render will not be visible in the console. 194 |
195 | 196 | {isOpen && } 197 |