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-perf-x

v0.1.0

Published

Lightweight React performance optimization library — hooks, HOCs, and utilities for detecting re-renders, smart memoization, and profiling.

Readme

ReactPerfX ⚡

Lightweight, tree-shakable React performance optimization library — zero external dependencies, TypeScript-first.

CI npm License: MIT Bundle Size

Install

npm install react-perf-x

Features

| Feature | Import | Description | |---------|--------|-------------| | useRenderTracker | Hook | Log render counts with optional warning threshold | | useWhyDidYouRender | Hook | Log exactly which props/state changed on re-render | | useDeepCompareEffect | Hook | useEffect with deep dependency comparison | | useDeepCompareMemo | Hook | useMemo with deep dependency comparison | | useDebounce | Hook | Debounce any value | | useThrottle | Hook | Throttle any value | | usePrevious | Hook | Track previous value of any state/prop | | useRenderCount | Hook | Get current render count as a number | | useLazyRef | Hook | Lazy initialization for expensive refs | | withSmartMemo | HOC | Deep-comparison memoization with custom comparator | | PerformanceProfiler | Component | Measure component render duration | | deepCompare | Utility | Deep equality comparison | | isDev | Utility | Check if running in development mode |

Quick Start

Track Re-renders

import { useRenderTracker } from "react-perf-x";

function Dashboard() {
  useRenderTracker("Dashboard", { warnAfter: 10 });
  return <div>...</div>;
}

Debug Why Components Re-render

import { useWhyDidYouRender } from "react-perf-x";

function UserCard({ name, age, filters }) {
  useWhyDidYouRender("UserCard", { name, age, filters });
  // Console: [UserCard] Re-rendered because:
  //   filters changed:
  //     prev: {status: "active"}
  //     next: {status: "inactive"}
  return <div>{name}</div>;
}

Deep Compare Effect

import { useDeepCompareEffect } from "react-perf-x";

function DataList({ filters }) {
  useDeepCompareEffect(() => {
    fetchData(filters); // Only re-fetches when filters *deeply* change
  }, [filters]);
  return <div>...</div>;
}

Debounce & Throttle

import { useDebounce, useThrottle } from "react-perf-x";

function SearchBox({ query }) {
  const debouncedQuery = useDebounce(query, 300);
  const throttledScroll = useThrottle(scrollPosition, 100);
}

Smart Memoization

import { withSmartMemo } from "react-perf-x";

const MemoizedCard = withSmartMemo(UserCard);
// Uses deep comparison — won't re-render if props are deeply equal

// With custom comparator:
const CustomMemo = withSmartMemo(UserCard, (prev, next) => prev.id === next.id);

Performance Profiling

import { PerformanceProfiler } from "react-perf-x";

function App() {
  return (
    <PerformanceProfiler
      id="Dashboard"
      onProfile={({ id, duration }) => console.log(`${id}: ${duration}ms`)}
    >
      <Dashboard />
    </PerformanceProfiler>
  );
}

API Reference

Hooks

useRenderTracker(componentName, options?)

  • componentName: string — Name shown in logs
  • options.warnAfter?: number — Warn after this many renders

useWhyDidYouRender(componentName, props)

  • componentName: string — Name shown in logs
  • props: Record<string, any> — Object of values to track

useDeepCompareEffect(effect, deps)

  • Same API as useEffect, but deep-compares dependencies

useDeepCompareMemo(factory, deps)

  • Same API as useMemo, but deep-compares dependencies

useDebounce<T>(value, delay): T

  • Returns debounced value after delay ms of inactivity

useThrottle<T>(value, delay): T

  • Returns throttled value, updating at most once per delay ms

usePrevious<T>(value): T | undefined

  • Returns value from the previous render

useRenderCount(): number

  • Returns current render count

useLazyRef<T>(initializer): MutableRefObject<T>

  • Lazily initializes ref value (initializer runs once)

HOC

withSmartMemo<T>(Component, comparator?)

  • comparator?: (prev, next) => boolean — Custom comparator (defaults to deepCompare)

Components

<PerformanceProfiler id? onProfile?>

  • id?: string — Identifier for the profiled component
  • onProfile?: (metrics: { id, duration }) => void — Callback with render metrics

Requirements

  • React 18+
  • TypeScript 5+ (recommended)

Development

npm install        # Install dependencies
npm test           # Run tests
npm run test:coverage  # Run tests with coverage
npm run lint       # Lint source files
npm run build      # Build ESM + CJS bundles

License

MIT