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-hooks-essentials

v1.0.0

Published

![npm](https://img.shields.io/npm/v/react-hooks-essentials) ![typings: included](https://img.shields.io/badge/typings-included-brightgreen) ![dependencies: 0](https://img.shields.io/badge/dependencies-0-brightgreen)

Readme

React Hooks Essentials

npm typings: included dependencies: 0

A small collection of React hooks, designed to make general hooks usage simpler.

useMethod()

An alternative to React's useCallback(), without the fuss of dependencies or volatile function references.

const myFunc = useMethod((...args) => {
    // do stuff
});

// ...

const x = myFunc(...args); // Acts exactly like the input function

Use as you would useCallback(), but without the dependencies array. The returned function will do exactly as the inner function would, but wraps it in such a way that the output function never changes reference, but always has the up-to-date functionality.

As a result, the function doesn't need a dependency array, and doesn't need to be included in those of other callbacks, effects, etc.

Example

Vs. useCallback() and unwrapped functions

| | useMethod | useCallback | Inline function | | ----------------------------------- | :----------------: | :--------------: | :--------------: | | Requires deps array | ✘ | ✔ | ✘ | | Changes reference | Never | When deps change | Every update | | Needs to be included in deps arrays | ✘ | ✔ | ✔ (but not safe) | | Safe to include in deps arrays | ✔ (but not needed) | ✔ | ✘ | | Safe to use in async code | ✔ | ✘ | ✘ |

When not to use it

  • When you specifically want the function to change only when the deps change (use useCallback()).

useGetter()

Returns a getter function for the input value.

const getValue = useGetter(props.value);

// ...

const x = getValue(); // Up-to-date value of props.value.

The returned function, like those returned by useMethod(), is single-instance, meaning it doesn't need to be included in dependencies arrays, and is safe to use in asynchronous code.

useObject()

Returns a single-instance object, which is always updated with the contents of its input.

As with the other hooks, the returned object is updated rather than replaced, so it does not need to be included in dependency arrays, and is safe to use in asynchronous code.

This can also be useful for creating an object to be passed down through the Context API, if the consumers don't need to be notified of changes.

const obj = useObject({
    a: someVolatileValue,
    b: anotherVolatileValue
});

// ...

const x = obj.a; // The up-to-date value of someVolatileValue

useSelf()

Provides single-instance functions related to the component lifecycle.

Currently this is only isMounted().

self.isMounted()

A function which indicates whether the containing component is still mounted.

const self = useSelf();

// ...

if (self.isMounted()) {
    // do stuff that's only safe while mounted (e.g. setState())
}