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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-use-more

v1.0.0

Published

A set of supplementary React hooks

Downloads

59

Readme

react-use-more

A collection of additional React hooks for common use cases beyond what is included in the React core. These hooks are meant to be basic building blocks for React projects, covering functionality that is useful but not necessarily included in the core library.

Installation

npm install react-use-more

Hooks

useForceUpdate

Provides a function that forces the component it was created in to re-render when called. This is only intended as a last resort and should be avoided in favor of restructuring your component state.

useInstantRef

This hook tracks the value most recently passed in, making it instantly available as a ref. It has the most up-to-date value when accessed through a stale callback.

useMember

This hook retains the same value for the entire lifetime of a component. It's initialized by calling the factory function provided to it on first render, and the factory function is never called again. This hook is intended to act like members in class components.

useMemberRef

This hook functions identically to useMember, but returns a ref. This allows the value to be fully replaced any time after initialization.

useMounted

This hook returns a function that can be called anywhere and anytime to determine if the component is currently mounted. This is useful when working with asynchronous code or when needing to know the mounted state of the component outside of the render cycle. The function returned by useMounted will always have the same identity, so it can be safely passed as a dependency to other hooks or functions without causing unnecessary re-renders.

useOnUnmount

This hook allows you to register a cleanup function that will be called when a component unmounts. It ensures that the function passed to it is the most recent one, as opposed to just returning a cleanup function from useEffect with an empty dependency list (useEffect(() => cleanup, [])), which would call the function passed to it on mount, which could be out-of-date.

Legacy Hooks

useComplexState

This hook manages a state object that can be partially updated. It's similar to setState in class components, but in the form of useState for functional components. This allows for updating only a part of the state object rather than the entire object at once.

~~useComplexSetter~~ (DEPRECATED)

This hook returns a function that updates a single field of a complex state through a single parameter. It works with useComplexState or any other custom state hook that provides a setState function with the same interface.

~~useComplexSetterTransformative~~ (DEPRECATED)

This hook functions identically to useComplexSetter, but allows for transforming the value before it's set. This can be useful for extracting updated values from input fields or other computations.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT