GithubHelp home page GithubHelp logo

toli444 / react-compiler-playground-app Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 55 KB

A developer playground app to test how React Compiler will optimize re-renders in React applications.

License: MIT License

JavaScript 55.12% HTML 10.10% CSS 34.78%
react react-compiler react19

react-compiler-playground-app's Introduction

React Compiler playground app ✨✨✨

This project provides a minimal setup for a React 19 app powered by React Compiler. In this developer playground you can prototype and test how React Compiler will optimize re-renders in React applications.

Quick start

npm install
npm run dev

In ./src/App.jsx you can add components you want to test. You can use console.log to check which components re-render and when.

Checking if components have been optimized

You can use React Devtools (v5.0+), which has built-in support for React Compiler and will display a “Memo ✨” badge next to components that have been optimized by the compiler.

In React Devtools, you can also enable “Highlight updates when components render” option for a visual indication when components rerender (However, I found that it does not always accurately work with components optimized by React Compiler, so using console.log to check if the component is re-rendered seems more reliable as of now).

Checking how components have been optimized

Minification is disabled in this project, so when you don't understand why some components are being re-rendered when you think they shouldn't, you can build this project with npm run build and examine the dist folder to see the output of the React Compiler (open ./dist/assets/index-*.js and scroll to the bottom).

You can also copy your code to React Compiler online playground and see the compilation result there.

Running app example

Example of the project running and how it can be used to detect unexpected behavior of React Compiler:

running_app_example

Read more about it in this article about React Compiler common memoization “gotcha”.

How the project is setup

https://react.dev/learn/react-compiler#usage-with-vite

react-compiler-playground-app's People

Contributors

toli444 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.