npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-debug-flow

v0.1.3

Published

A dev-only React hook that shows exactly why your component re-rendered, in plain English.

Downloads

425

Readme

react-debug-flow

A dev-only React hook that tells you exactly why your component re-rendered — in plain English.

npm version bundle size license TypeScript


The problem

You add a console.log inside a component. It fires 6 times. You stare at React DevTools. You Google "why is my component re-rendering". Sound familiar?

// React DevTools shows you a tree. Not helpful.
// why-did-you-render dumps a raw object diff. Hard to read.
// Neither tells you what it actually MEANS.

The solution

One line. Drop it in any component:

import { useDebugFlow } from 'react-debug-flow';

function UserCard({ userId, filters, onSelect }) {
  useDebugFlow('UserCard', { userId, filters, onSelect });
  // ...
}

A floating badge appears directly on your component:

┌─────────────────────────────────────────────────┐
│  <UserCard>  render #3                          │
│─────────────────────────────────────────────────│
│  component   <UserCard>                         │
│  renders     #3                                 │
│  reason      `onSelect` is a new function       │
│              reference — wrap it in useCallback │
│  changed     `onSelect`                         │
└─────────────────────────────────────────────────┘

Zero config. Zero runtime dependencies. Automatically stripped in production.


Install

npm install react-debug-flow
# or
yarn add react-debug-flow
# or
pnpm add react-debug-flow

Usage

Basic — useDebugFlow hook

import { useDebugFlow } from 'react-debug-flow';

function ProductList({ filters, page, onPageChange }) {
  const overlay = useDebugFlow('ProductList', { filters, page, onPageChange });

  return (
    <div style={{ position: 'relative' }}>
      {overlay}
      {/* rest of your JSX */}
    </div>
  );
}

Console mode

Prefer your browser console over an overlay?

useDebugFlow('MyComponent', props, { output: 'console' });
// or show both at once
useDebugFlow('MyComponent', props, { output: 'both' });

Global config — DebugFlowProvider

Set defaults once at your app root so you don't repeat options everywhere:

import { DebugFlowProvider } from 'react-debug-flow';

export default function App() {
  return (
    <DebugFlowProvider config={{ output: 'console', maxHistory: 20 }}>
      <YourApp />
    </DebugFlowProvider>
  );
}

HOC — withDebugFlow

For class components, or when you can't edit the component source:

import { withDebugFlow } from 'react-debug-flow';

const DebuggedList = withDebugFlow(MyList, 'MyList');
// Use <DebuggedList /> exactly like <MyList />

Custom callback — onRender

Pipe render info into your own logging or analytics system:

useDebugFlow('Dashboard', props, {
  output: 'console',
  onRender: (info) => {
    console.table(info.changedProps);
  },
});

API Reference

useDebugFlow(componentName, props?, options?)

| Parameter | Type | Description | |---|---|---| | componentName | string | Name shown in the overlay and console | | props | Record<string, unknown> | The component's props to track | | options | DebugFlowOptions | Per-component config (overrides Provider) |

Returns React.ReactElement | null — render the returned value inside your component to show the overlay.

DebugFlowOptions

| Option | Type | Default | Description | |---|---|---|---| | output | 'overlay' \| 'console' \| 'both' | 'overlay' | Where to surface debug info | | maxHistory | number | 10 | How many renders to keep in memory | | highlight | boolean | true | Flash a border on each re-render | | collapsed | boolean | false | Start the overlay collapsed | | onRender | (info: RenderInfo) => void | undefined | Custom callback fired on every render |

RenderInfo

interface RenderInfo {
  componentName: string;
  renderCount:   number;
  changedProps:  { key: string; prev: unknown; next: unknown }[];
  reason:        string;   // plain English — e.g. "`userId` changed (1 → 2)"
  timestamp:     number;
}

Production safety

Every code path is guarded by:

if (process.env.NODE_ENV === 'production') return null;

Modern bundlers (Vite, webpack, esbuild, Parcel) tree-shake this to zero bytes in your production bundle. You never need to remove it before shipping.


How it compares

| | React DevTools | why-did-you-render | react-debug-flow | |---|:---:|:---:|:---:| | Browser extension required | ✅ | ❌ | ❌ | | In-app visual overlay | ❌ | ❌ | ✅ | | Plain English explanations | ❌ | ❌ | ✅ | | Beginner-friendly output | ❌ | ❌ | ✅ | | Warns about unstable function props | ❌ | partial | ✅ | | Works in CI / test output | ❌ | ✅ | ✅ | | Zero runtime dependencies | ✅ | ✅ | ✅ |


Contributing

PRs and issues are welcome!

git clone https://github.com/abdullah-al-monir/react-debug-flow
cd react-debug-flow
npm install
npm run dev    # build in watch mode
npm test       # run tests

License

MIT © Abdullah Al Monir