AI summary by TwinMind

Why is every React site so slow?

Theo - t3․gg

13m 52s

React Rendering Problem Overview

  • React has significant rendering performance issues visible on major sites
  • GitHub example shows flickering components during scroll navigation
  • Problem affects user experience across popular websites
  • Need to understand what "render" actually means in React context

Sponsor Segment - PostHog

  • PostHog: all-in-one product analytics and tools suite
  • Features: analytics, feature flags, surveys, AI engineering
  • 90%+ companies use free tier
  • Open source with self-hosting option
  • Cloud platform cheap and effective
  • Used by presenter for years across all products

Understanding React Renders

  • Render ≠ DOM element reappearing on page
  • Virtual DOM created to address real DOM manipulation performance issues
  • React checks everything from state change point downward in component tree
  • Virtual DOM diffing process:
    • Current virtual DOM vs new virtual DOM comparison
    • Only actual changes applied to real DOM
    • Unnecessary checks happen even when nothing changes
  • "Render" typically means unnecessary checks between virtual DOM states

Demo Application Analysis

  • Simple React app with: Color Picker, Counter, Slow Component
  • Counter clicks trigger re-renders of all components (Color Picker, Slow Component)
  • State defined at top level causes all children to re-check
  • React assumes components might have changed, renders "just in case"
  • Default behavior: always check unless told not to with memoization

Memoization Solutions

  • Traditional solution: React.memo for components, useCallback for functions
  • Manual memoization tedious and error-prone
  • Easy to break with inline objects/functions
  • Example: passing {hello: "world"} inline breaks memoization
  • Requires careful prop management and stable references

Slow Component Performance Impact

  • Large array rendering (10,000 elements)
  • Creates significant computational work
  • Color picker drag becomes laggy due to slow component re-renders
  • Commenting out slow component fixes performance immediately
  • Real-world impact on user interactions

React Compiler Solution

  • Automatically adds memoization without code changes
  • Eliminates need for manual React.memo and useCallback
  • Handles inline objects/unstable references correctly
  • Goal: remove need for useMemo and React.memo from codebases entirely
  • Transforms poorly optimized code into well-optimized automatically

Real-World Performance Issues

  • Pinterest: drops to 60fps on high-end MacBook during scroll
  • DoorDash: drops to 1fps when toggling delivery/pickup settings
  • GitHub: visible flickering during navigation
  • Twitch: complex codebase with performance challenges
  • Common across major websites due to lack of proper memoization

React Scan Tool

  • Easy visualization of component re-renders
  • Simple setup: include unpkg.com URL for react-scan
  • Works in development and production
  • Quick visual feedback vs deep diving with React DevTools
  • Helps identify unnecessary re-renders instantly

Million Lint Tool

  • Company building React performance solutions
  • Originally alternative React runtime, now performance tooling
  • Shows slow elements directly in editor
  • Browser extension for performance insights
  • Identifies slow next paint issues
  • Integration with development workflow

TwinMind

Get summaries like this for your own meetings

TwinMind takes notes in the background during meetings, lectures, and calls, then writes the summary for you.

Free plan to get started

No bot joins your calls

Phone, desktop & Chrome apps

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome