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

@frugalwizard/random-react-utils

v0.2.0

Published

Random React Utils

Downloads

1

Readme

README

What is this?

This is compilation of random utilities for building React apps.

Should I use this?

Currently it's not to be considered stable.

Use at your own discretion and don't rely on anything staying backward compatible.

What utilities are included here?

  • abortable

    A wrapper for effects that use an AbortSignal.

  • asynced

    A wrapper for async effects.

  • Nested

    A component that handles nesting multiple no args components.

  • nonexistent

    A symbol/type to mark state as non-existent.

  • noop

    An empty function. Useful when such a function is required and it being a stable value is preferable.

  • onClickOutside

    A helper for setting up listener to clicks that happen outside an element.

  • pending

    A symbol/type to mark state as pending.

  • preventDefault

    A function that calls preventDefault on its first argument. Useful for some use cases with event handlers.

  • pushState

    A function to push an url/state into navigation history. Also triggers the corresponding popstate event.

  • useBoolean

    An useState alternative for boolean flags.

  • useBooleanToggle

    Another useState alternative for boolean flags.

  • useCursor

    A useState alternative for handling cursors over numerically indexed lists (e.g. pagination).

  • useFunctionRef

    A mutable function reference. Useful when you need to keep a callback for later without keeping it as part of the component state.

  • useLoadingFlag

    A hook for dynamically keeping track of one or more Promises and providing a flag that indicates whether there are pending Promises or not.

  • useLocation

    Returns the current URL and causes the component to rerender when it changes. Useful to handle URL routing yourself.

  • useMediaQuery

    Indicates whether the current viewport matches a media query and causes a rerender if the condition changes.

  • useMutable

    A hook for handling a mutable value. Useful for keeping track of data during the component lifecycle that does not need to be part of the component state.

  • useResizeDetect

    A flag which indicates when the viewport is view resized.

  • useSharedState

    A way for components to share state and/or prevent unnecessary rerenders and coupling between parent and child components.

  • useSingleton

    An alternative to React's useContext.

  • useUnmountSignal

    An AbortSignal that triggers when the component unmounts. Useful for async callbacks that need to be aborted when the component unmounts.