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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rerender-react

v0.1.0

Published

Easy handling of object state updates in React components

Downloads

12

Readme

React-Refresh

A utility library for handling object state updates in React components.

React's useState hook triggers re-renders when the state value changes. However, when you mutate properties of an object without replacing the whole object, React does not detect the change. react-refresh provides a simple context and hook API to force re-renders on demand.

Peer Dependency: React (>=16.8)

Package: [email protected]

Features

  • RefreshProvider component to wrap parts of your app.
  • useRefresh hook to access a refresh() function.
  • Calling refresh() forces a re-render of all components under the provider.

Installation

npm install react-refresh
# or
yarn add react-refresh

Usage

Wrap your application (or any subtree) with RefreshProvider:

import React from 'react';
import ReactDOM from 'react-dom';
import { RefreshProvider } from 'react-refresh';
import App from './App';

ReactDOM.render(
  <RefreshProvider>
    <App />
  </RefreshProvider>,
  document.getElementById('root')
);

In any component under the provider, use the useRefresh hook:

import React from 'react';
import { useRefresh } from 'react-refresh';

type Data = { name: string; [key: string]: any };

function MyComponent({ data }: { data: Data }) {
  const { refresh } = useRefresh();

  const handleChange = () => {
    // Mutate object properties...
    data.name = 'New Name';
    // Force React to re-render to pick up changes
    refresh();
  };

  return (
    <div>
      <span>{data.name}</span>
      <button onClick={handleChange}>Change Name</button>
    </div>
  );
}

API

RefreshProvider

A React context provider that exposes the refresh function to its children.

Props:

  • children: React.ReactNode – Components that should be able to trigger a refresh.

useRefresh

Hook to access the refresh() function.

Returns:

  • { refresh: () => void } – Call refresh() to force a re-render of the provider's subtree.

Limitations

  • Calling refresh() forces a full re-render of the provider's subtree; use it judiciously to avoid performance issues.

Development

git clone <repo-url>
cd react-refresh
npm install
npm run build
npm test

Build

npm run build

Test

Tests are written using Jest and react-test-renderer.

npm test

License

MIT