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

@custardcream/babel-plugin-react-effect-namer

v0.0.3

Published

Babel plugin for naming effect hook callbacks

Downloads

3

Readme

  • Better Debuggability: Meaningful function names help generate clearer stack traces.
  • Enhanced Readability: Cleaner, self-documenting code.
  • Non-Intrusive: Only transforms callbacks that are anonymous.

Overview

This plugin automatically transforms anonymous callbacks passed to React's useEffect and useLayoutEffect into named functions. Providing explicit names results in clearer stack traces during debugging and makes your code easier to understand.


Features

  • Transforms Arrow Functions: Converts arrow functions into named function expressions.
  • Transforms Anonymous Function Expressions: Converts standard anonymous functions to named ones.
  • Unique Naming: Automatically assigns unique names (e.g., MyComponent_useEffect_1, MyComponent_useEffect_2) when multiple effects are present.
  • Safe Transformations: Leaves already named functions untouched.

devtools example

You can check effect hook names on stack traces.


Installation

npm install --save-dev @custardcream/babel-plugin-react-effect-namer

Usage

Configure Babel to use the plugin. Here’s an example using a babel.config.js:

module.exports = {
  plugins: ['@custardcream/babel-plugin-react-effect-namer'],
};

Once configured, any React component using useEffect or useLayoutEffect with an anonymous callback will be transformed.


Examples

1. Transforming an Arrow Function Callback

Before transformation:

import React, { useEffect } from 'react';

function MyComponent() {
  useEffect(() => {
    console.log('Effect run');
  }, []);

  return <div>Hello</div>;
}

After transformation (the actual output might vary in formatting):

import React, { useEffect } from 'react';

function MyComponent() {
  const MyComponent_useEffect_1 = () => {
    console.log('Effect run');
  };

  useEffect(MyComponent_useEffect_1, []);

  return <div>Hello</div>;
}

2. Transforming an Anonymous Function Expression

Before transformation:

import React, { useEffect } from 'react';

function MyComponent() {
  useEffect(function () {
    console.log('Effect run');
  }, []);

  return <div>Hello</div>;
}

After transformation:

import React, { useEffect } from 'react';

function MyComponent() {
  function MyComponent_useEffect_1() {
    console.log('Effect run');
  }

  useEffect(MyComponent_useEffect_1, []);

  return <div>Hello</div>;
}

3. Handling Multiple Effect Hook Calls

When a component has more than one effect hook call, the plugin assigns unique names to each callback.

Before transformation:

import React, { useEffect } from 'react';

function MyComponent() {
  useEffect(() => {
    console.log('First effect');
  }, []);

  useEffect(() => {
    console.log('Second effect');
  }, []);

  return <div>Hello</div>;
}

After transformation:

useEffect(MyComponent_useEffect_1, []);
useEffect(MyComponent_useEffect_2, []);