# welldone-software/why-did-you-render architecture

> Architecture diagram of the GitHub repository welldone-software/why-did-you-render, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/welldone-software/why-did-you-render
- Repository: https://github.com/welldone-software/why-did-you-render

## Overview

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: [`src/whyDidYouRender.js`](https://github.com/welldone-software/why-did-you-render/blob/master/src/whyDidYouRender.js) (React patch initializer), [`src/patches/patchFunctionalOrStrComponent.js`](https://github.com/welldone-software/why-did-you-render/blob/master/src/patches/patchFunctionalOrStrComponent.js) (Function wrapper), [`src/defaultNotifier.js`](https://github.com/welldone-software/why-did-you-render/blob/master/src/defaultNotifier.js) (Default notifier), [`src/wdyrStore.js`](https://github.com/welldone-software/why-did-you-render/blob/master/src/wdyrStore.js) (Runtime tracking state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Application integration"]
  node_app["React application"]
  node_jsx["JSX entry points<br/>[jsx-runtime.js]"]
  node_api["Library entry API<br/>[index.js]"]
end

subgraph group_instrumentation["React instrumentation"]
  node_initializer["React patch initializer<br/>[whyDidYouRender.js]"]
  node_tracking["Component tracking<br/>[shouldTrack.js]"]
  node_classpatch["Class wrapper"]
  node_functionpatch["Function wrapper"]
  node_memopatch["Memo wrapper"]
  node_forwardpatch["Forward-ref wrapper"]
  node_hooktracking["Hook tracking<br/>[whyDidYouRender.js]"]
end

subgraph group_analysis["Change analysis"]
  node_updateinfo["Update reason assembly<br/>[getUpdateInfo.js]"]
  node_objectdiff["Object differences"]
  node_deepdiff["Deep value differences"]
  node_diffmodel["Difference types<br/>[consts.js]"]
end

subgraph group_reporting["Reporting and state"]
  node_store["Runtime tracking state<br/>[wdyrStore.js]"]
  node_ownerdata["Owner context helpers<br/>[helpers.js]"]
  node_notifier["Default notifier<br/>[defaultNotifier.js]"]
  node_printer["Difference printer<br/>[printDiff.js]"]
  node_options["Option normalization"]
end

node_developer(("Application developer"))
node_react["React runtime"]
node_console["Developer console"]

node_developer -->|"configures"| node_app
node_app -->|"initializes first"| node_api
node_developer -->|"configures import"| node_jsx
node_jsx -.->|"imports library runtime"| node_api
node_api -->|"exports initializer"| node_initializer
node_api -->|"exposes state"| node_store
node_initializer -->|"patches element APIs"| node_react
node_initializer -->|"normalizes options"| node_options
node_initializer -->|"checks eligibility"| node_tracking
node_initializer -->|"selects wrapper"| node_classpatch
node_initializer -->|"selects wrapper"| node_functionpatch
node_initializer -->|"selects wrapper"| node_memopatch
node_initializer -->|"selects wrapper"| node_forwardpatch
node_initializer -->|"rewrites hooks"| node_hooktracking
node_initializer -->|"records runtime state"| node_store
node_classpatch -->|"assembles reason"| node_updateinfo
node_functionpatch -->|"assembles reason"| node_updateinfo
node_memopatch -->|"delegates class"| node_classpatch
node_memopatch -->|"delegates function"| node_functionpatch
node_forwardpatch -->|"delegates rendering"| node_functionpatch
node_hooktracking -->|"assembles hook reason"| node_updateinfo
node_updateinfo -->|"compares values"| node_objectdiff
node_objectdiff -->|"computes deep diffs"| node_deepdiff
node_deepdiff -->|"uses diff types"| node_diffmodel
node_updateinfo -->|"reads owner data"| node_store
node_classpatch -->|"reads tracking state"| node_store
node_classpatch -->|"submits update"| node_notifier
node_functionpatch -->|"reads tracking state"| node_store
node_functionpatch -->|"submits update"| node_notifier
node_notifier -->|"reads options and owners"| node_store
node_notifier -->|"prints detailed diff"| node_printer
node_printer -->|"calculates diff"| node_deepdiff
node_notifier -->|"writes reports"| node_console
node_initializer -->|"gets current owner"| node_ownerdata
node_api -->|"sets default notifier"| node_notifier

click node_jsx "https://github.com/welldone-software/why-did-you-render/blob/master/jsx-runtime.js"
click node_api "https://github.com/welldone-software/why-did-you-render/blob/master/src/index.js"
click node_initializer "https://github.com/welldone-software/why-did-you-render/blob/master/src/whyDidYouRender.js"
click node_tracking "https://github.com/welldone-software/why-did-you-render/blob/master/src/shouldTrack.js"
click node_classpatch "https://github.com/welldone-software/why-did-you-render/blob/master/src/patches/patchClassComponent.js"
click node_functionpatch "https://github.com/welldone-software/why-did-you-render/blob/master/src/patches/patchFunctionalOrStrComponent.js"
click node_memopatch "https://github.com/welldone-software/why-did-you-render/blob/master/src/patches/patchMemoComponent.js"
click node_forwardpatch "https://github.com/welldone-software/why-did-you-render/blob/master/src/patches/patchForwardRefComponent.js"
click node_hooktracking "https://github.com/welldone-software/why-did-you-render/blob/master/src/whyDidYouRender.js"
click node_updateinfo "https://github.com/welldone-software/why-did-you-render/blob/master/src/getUpdateInfo.js"
click node_objectdiff "https://github.com/welldone-software/why-did-you-render/blob/master/src/findObjectsDifferences.js"
click node_deepdiff "https://github.com/welldone-software/why-did-you-render/blob/master/src/calculateDeepEqualDiffs.js"
click node_diffmodel "https://github.com/welldone-software/why-did-you-render/blob/master/src/consts.js"
click node_store "https://github.com/welldone-software/why-did-you-render/blob/master/src/wdyrStore.js"
click node_ownerdata "https://github.com/welldone-software/why-did-you-render/blob/master/src/helpers.js"
click node_notifier "https://github.com/welldone-software/why-did-you-render/blob/master/src/defaultNotifier.js"
click node_printer "https://github.com/welldone-software/why-did-you-render/blob/master/src/printDiff.js"
click node_options "https://github.com/welldone-software/why-did-you-render/blob/master/src/normalizeOptions.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_jsx,node_api toneBlue
class node_initializer,node_tracking,node_classpatch,node_functionpatch,node_memopatch,node_forwardpatch,node_hooktracking toneAmber
class node_updateinfo,node_objectdiff,node_deepdiff,node_diffmodel toneMint
class node_store,node_ownerdata,node_notifier,node_printer,node_options toneRose
class node_developer,node_react,node_console toneIndigo
```

## Components

### Application integration

- **React application**
- [JSX entry points](https://github.com/welldone-software/why-did-you-render/blob/master/jsx-runtime.js): `jsx-runtime.js`
- [Library entry API](https://github.com/welldone-software/why-did-you-render/blob/master/src/index.js): `src/index.js`

### React instrumentation

- [React patch initializer](https://github.com/welldone-software/why-did-you-render/blob/master/src/whyDidYouRender.js): `src/whyDidYouRender.js`
- [Component tracking](https://github.com/welldone-software/why-did-you-render/blob/master/src/shouldTrack.js): `src/shouldTrack.js`
- [Class wrapper](https://github.com/welldone-software/why-did-you-render/blob/master/src/patches/patchClassComponent.js): `src/patches/patchClassComponent.js`
- [Function wrapper](https://github.com/welldone-software/why-did-you-render/blob/master/src/patches/patchFunctionalOrStrComponent.js): `src/patches/patchFunctionalOrStrComponent.js`
- [Memo wrapper](https://github.com/welldone-software/why-did-you-render/blob/master/src/patches/patchMemoComponent.js): `src/patches/patchMemoComponent.js`
- [Forward-ref wrapper](https://github.com/welldone-software/why-did-you-render/blob/master/src/patches/patchForwardRefComponent.js): `src/patches/patchForwardRefComponent.js`
- [Hook tracking](https://github.com/welldone-software/why-did-you-render/blob/master/src/whyDidYouRender.js): `src/whyDidYouRender.js`

### Change analysis

- [Update reason assembly](https://github.com/welldone-software/why-did-you-render/blob/master/src/getUpdateInfo.js): `src/getUpdateInfo.js`
- [Object differences](https://github.com/welldone-software/why-did-you-render/blob/master/src/findObjectsDifferences.js): `src/findObjectsDifferences.js`
- [Deep value differences](https://github.com/welldone-software/why-did-you-render/blob/master/src/calculateDeepEqualDiffs.js): `src/calculateDeepEqualDiffs.js`
- [Difference types](https://github.com/welldone-software/why-did-you-render/blob/master/src/consts.js): `src/consts.js`

### Reporting and state

- [Runtime tracking state](https://github.com/welldone-software/why-did-you-render/blob/master/src/wdyrStore.js): `src/wdyrStore.js`
- [Owner context helpers](https://github.com/welldone-software/why-did-you-render/blob/master/src/helpers.js): `src/helpers.js`
- [Default notifier](https://github.com/welldone-software/why-did-you-render/blob/master/src/defaultNotifier.js): `src/defaultNotifier.js`
- [Difference printer](https://github.com/welldone-software/why-did-you-render/blob/master/src/printDiff.js): `src/printDiff.js`
- [Option normalization](https://github.com/welldone-software/why-did-you-render/blob/master/src/normalizeOptions.js): `src/normalizeOptions.js`

### Other components

- **Application developer**
- **React runtime**
- **Developer console**

## Connections

- Application developer → React application: configures (evidence: `README.md`)
- React application → Library entry API: initializes first (evidence: `README.md`)
- Application developer → JSX entry points: configures import (evidence: `README.md`)
- JSX entry points → Library entry API: imports library runtime
- Library entry API → React patch initializer: exports initializer (evidence: `src/index.js`)
- Library entry API → Runtime tracking state: exposes state (evidence: `src/index.js`)
- React patch initializer → React runtime: patches element APIs (evidence: `src/whyDidYouRender.js`)
- React patch initializer → Option normalization: normalizes options (evidence: `src/whyDidYouRender.js`)
- React patch initializer → Component tracking: checks eligibility (evidence: `src/whyDidYouRender.js`)
- React patch initializer → Class wrapper: selects wrapper (evidence: `src/whyDidYouRender.js`)
- React patch initializer → Function wrapper: selects wrapper (evidence: `src/whyDidYouRender.js`)
- React patch initializer → Memo wrapper: selects wrapper (evidence: `src/whyDidYouRender.js`)
- React patch initializer → Forward-ref wrapper: selects wrapper (evidence: `src/whyDidYouRender.js`)
- React patch initializer → Hook tracking: rewrites hooks (evidence: `src/whyDidYouRender.js`)
- React patch initializer → Runtime tracking state: records runtime state (evidence: `src/whyDidYouRender.js`)
- Class wrapper → Update reason assembly: assembles reason (evidence: `src/patches/patchClassComponent.js`)
- Function wrapper → Update reason assembly: assembles reason (evidence: `src/patches/patchFunctionalOrStrComponent.js`)
- Memo wrapper → Class wrapper: delegates class (evidence: `src/patches/patchMemoComponent.js`)
- Memo wrapper → Function wrapper: delegates function (evidence: `src/patches/patchMemoComponent.js`)
- Forward-ref wrapper → Function wrapper: delegates rendering (evidence: `src/patches/patchForwardRefComponent.js`)
- Hook tracking → Update reason assembly: assembles hook reason (evidence: `src/whyDidYouRender.js`)
- Update reason assembly → Object differences: compares values (evidence: `src/getUpdateInfo.js`)
- Object differences → Deep value differences: computes deep diffs (evidence: `src/findObjectsDifferences.js`)
- Deep value differences → Difference types: uses diff types (evidence: `src/calculateDeepEqualDiffs.js`)
- Update reason assembly → Runtime tracking state: reads owner data (evidence: `src/getUpdateInfo.js`)
- Class wrapper → Runtime tracking state: reads tracking state (evidence: `src/patches/patchClassComponent.js`)
- Class wrapper → Default notifier: submits update (evidence: `src/patches/patchClassComponent.js`)
- Function wrapper → Runtime tracking state: reads tracking state (evidence: `src/patches/patchFunctionalOrStrComponent.js`)
- Function wrapper → Default notifier: submits update (evidence: `src/patches/patchFunctionalOrStrComponent.js`)
- Default notifier → Runtime tracking state: reads options and owners (evidence: `src/defaultNotifier.js`)
- Default notifier → Difference printer: prints detailed diff (evidence: `src/defaultNotifier.js`)
- Difference printer → Deep value differences: calculates diff (evidence: `src/printDiff.js`)
- Default notifier → Developer console: writes reports (evidence: `src/defaultNotifier.js`)
- React patch initializer → Owner context helpers: gets current owner (evidence: `src/whyDidYouRender.js`)
- Library entry API → Default notifier: sets default notifier (evidence: `src/index.js`)
