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-cycle-guard

v1.0.2

Published

🛡️ A tiny dev-only React hook to detect excessive re-renders (like infinite loops)

Readme

🛡️ react-cycle-guard

Introducing react-cycle-guard — your React component’s personal bodyguard. It doesn’t block bad props or fight evil side effects, but it will throw itself between your app and an infinite render loop. It’s like useEffect()’s older sibling who says: "Hey. You’ve rendered 15 times this second. You okay, champ?"

In Simple Terms : A tiny React hook that helps you detect infinite loops and excessive re-renders — before they crash your app.


🚀 Why?

React renders are fast — but bugs aren’t. If your component:

  • Triggers a state update during render
  • Re-renders dozens of times per second
  • Gets stuck in a useEffect loop
  • Re-renders constantly from unstable props

…it can silently crush your app's performance or even cause a full browser crash.

react-cycle-guard is a tiny, dev-only hook that warns you when this is happening — right in your console.


💡 How It Works

It monitors how many times a component re-renders per second.

If it crosses a threshold (default: 10 renders/second), it shows a warning like:


📦 Install

npm install react-cycle-guard

🔧 Usage

import { useCycleGuard } from 'react-cycle-guard';

function ProductList(props) {
  useCycleGuard("ProductList");

  return <ul>{props.items.map(i => <li key={i.id}>{i.name}</li>)}</ul>;
}

That’s it. Now you’ll get a warning in the console if this component renders too often.


🐞 What Problems It Detects

🔁 1. Infinite Loops

function Buggy() {
  const [count, setCount] = useState(0);
  setCount(count + 1); // 🔥 Renders forever
  useCycleGuard("Buggy");
  return <div>{count}</div>;
}

⚠️ 2. Effects Without Dependencies

useEffect(() => {
  fetchData(); // sets state
}); // ❌ Missing deps — runs every render

useCycleGuard("Dashboard");

🔄 3. Re-renders from Parent Props

<ChildComponent onClick={() => doSomething()} />

// ✔️ Add useCycleGuard("ChildComponent") inside and catch it!

useCycleGuard("ChildComponent");

custom threshold

useCycleGuard("ChildComponent", 20); // 20 renders/second

🧼 Zero Prod Impact

This is a dev-only tool. Use it freely. It’s small, safe, and has no side effects.


✅ Ideal For

  • Debugging mysterious re-renders
  • Catching infinite render bugs fast
  • Preventing accidental prop spam from parents
  • Improving performance by exposing unnecessary updates

Enjoy ! 🎉