How welldone-software/why-did-you-render works
Why Did You Render is a development-time React instrumentation library: an application initializes it with React, then React element creation routes eligible components through wrappers that compare render inputs and report reasons. The main internal layers are component selection/patching, update-difference analysis, and notification; hook tracking and owner-reason reporting add distinct capabilities. The graph follows relationships shown in excerpts, source-index references, or README setup guidance. Some indexed modules were not excerpted, so their internal behavior and connections are not expanded.
Main entry points: whyDidYouRender.js React patch initializer · patchFunctionalOrStrComponent.js Function wrapper · defaultNotifier.js Default notifier · wdyrStore.js Runtime tracking state
Components 22
Application integration
- React application
- JSX entry points
jsx-runtime.js - Library entry API
src/index.js
React instrumentation
- React patch initializer
src/whyDidYouRender.js - Component tracking
src/shouldTrack.js - Class wrapper
src/patches/patchClassComponent.js - Function wrapper
src/patches/patchFunctionalOrStrComponent.js - Memo wrapper
src/patches/patchMemoComponent.js - Forward-ref wrapper
src/patches/patchForwardRefComponent.js - Hook tracking
src/whyDidYouRender.js
Change analysis
- Update reason assembly
src/getUpdateInfo.js - Object differences
src/findObjectsDifferences.js - Deep value differences
src/calculateDeepEqualDiffs.js - Difference types
src/consts.js
Reporting and state
- Runtime tracking state
src/wdyrStore.js - Owner context helpers
src/helpers.js - Default notifier
src/defaultNotifier.js - Difference printer
src/printDiff.js - Option normalization
src/normalizeOptions.js
Other components
- Application developer
- React runtime
- Developer console
Connections 35
- Application developer → React application: configures
README.md - React application → Library entry API: initializes first
README.md - Application developer → JSX entry points: configures import
README.md - JSX entry points → Library entry API: imports library runtime
- Library entry API → React patch initializer: exports initializer
src/index.js - Library entry API → Runtime tracking state: exposes state
src/index.js - React patch initializer → React runtime: patches element APIs
src/whyDidYouRender.js - React patch initializer → Option normalization: normalizes options
src/whyDidYouRender.js - React patch initializer → Component tracking: checks eligibility
src/whyDidYouRender.js - React patch initializer → Class wrapper: selects wrapper
src/whyDidYouRender.js - React patch initializer → Function wrapper: selects wrapper
src/whyDidYouRender.js - React patch initializer → Memo wrapper: selects wrapper
src/whyDidYouRender.js - React patch initializer → Forward-ref wrapper: selects wrapper
src/whyDidYouRender.js - React patch initializer → Hook tracking: rewrites hooks
src/whyDidYouRender.js - React patch initializer → Runtime tracking state: records runtime state
src/whyDidYouRender.js - Class wrapper → Update reason assembly: assembles reason
src/patches/patchClassComponent.js - Function wrapper → Update reason assembly: assembles reason
src/patches/patchFunctionalOrStrComponent.js - Memo wrapper → Class wrapper: delegates class
src/patches/patchMemoComponent.js - Memo wrapper → Function wrapper: delegates function
src/patches/patchMemoComponent.js - Forward-ref wrapper → Function wrapper: delegates rendering
src/patches/patchForwardRefComponent.js - Hook tracking → Update reason assembly: assembles hook reason
src/whyDidYouRender.js - Update reason assembly → Object differences: compares values
src/getUpdateInfo.js - Object differences → Deep value differences: computes deep diffs
src/findObjectsDifferences.js - Deep value differences → Difference types: uses diff types
src/calculateDeepEqualDiffs.js - Update reason assembly → Runtime tracking state: reads owner data
src/getUpdateInfo.js - Class wrapper → Runtime tracking state: reads tracking state
src/patches/patchClassComponent.js - Class wrapper → Default notifier: submits update
src/patches/patchClassComponent.js - Function wrapper → Runtime tracking state: reads tracking state
src/patches/patchFunctionalOrStrComponent.js - Function wrapper → Default notifier: submits update
src/patches/patchFunctionalOrStrComponent.js - Default notifier → Runtime tracking state: reads options and owners
src/defaultNotifier.js - Default notifier → Difference printer: prints detailed diff
src/defaultNotifier.js - Difference printer → Deep value differences: calculates diff
src/printDiff.js - Default notifier → Developer console: writes reports
src/defaultNotifier.js - React patch initializer → Owner context helpers: gets current owner
src/whyDidYouRender.js - Library entry API → Default notifier: sets default notifier
src/index.js