What Causes Renders?
In React, components re-render when:- State Changes - When a component’s state updates
- Props Changes - When parent components pass new props
- Context Changes - When a context value updates
- Parent Re-renders - When a parent component re-renders
The Reference Problem
React compares props by reference, not by value. This is intentional - rendering can be cheap to run. However, this makes it easy to accidentally cause unnecessary renders.onClick function and style object look the same, React creates new references on each render, triggering re-renders of ExpensiveComponent.
How React Scan Detects Renders
React Scan uses React’s internal instrumentation hooks to monitor your application in real-time.Fiber Tree Traversal
React Scan instruments React’s reconciliation process by hooking into the fiber tree:packages/scan/src/core/instrumentation.ts:524-528
Render Phases
React Scan tracks three render phases:- Mount (
0b001) - Component rendering for the first time - Update (
0b010) - Component re-rendering - Unmount (
0b100) - Component being removed
packages/scan/src/core/instrumentation.ts:37-41
Change Detection
For each render, React Scan collects detailed information about what changed:packages/scan/src/core/instrumentation.ts:140-150
Tracking Changes
Props Changes
React Scan detects when props change between renders:packages/scan/src/core/index.ts:187-193
State Changes
For functional components, React Scan tracks hook state:packages/scan/src/core/index.ts:169-175
For class components:
packages/scan/src/core/index.ts:176-182
Context Changes
React Scan also tracks context value changes:packages/scan/src/core/index.ts:194-201
Detecting Unnecessary Renders
An unnecessary render is defined as a component re-rendering with no change to its corresponding DOM subtree.packages/scan/src/core/instrumentation.ts:385-397
Performance Metrics
Render Timing
React Scan measures how long renders take:packages/scan/src/core/instrumentation.ts:607-625
FPS Tracking
React Scan monitors frames per second to detect performance degradation:packages/scan/src/core/instrumentation.ts:69-83
Visual Feedback
React Scan provides visual feedback through:- Outlines - Highlights components that render
- Color coding - Different colors indicate render frequency
- Toolbar - Shows FPS and notification count
- Inspector - Detailed breakdown of what changed
How does the highlight color work?
How does the highlight color work?
The outline color intensity and animation speed are based on how frequently a component renders. More frequent renders result in brighter, faster animations.
Why don't I see all renders?
Why don't I see all renders?
React Scan debounces renders within 16ms to avoid overwhelming the UI. Additionally, renders that don’t commit to the DOM may not be highlighted.
React Compiler Detection
React Scan automatically detects when components use React Compiler (formerly “React Forget”):Next Steps
- Learn how to optimize performance issues
- Set up custom monitoring
- Understand production usage