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

@bemedev/hook-wrapper

v1.0.0

Published

Wrapper of hooks to render them in a component without recreating them.

Readme

@bemedev/hook-wrapper

A lightweight utility to wrap React hooks and render them in a dedicated wrapper component. This isolates hook-driven updates, preventing unnecessary parent component rerenders and optimizing React application performance.

Why use @bemedev/hook-wrapper?

In standard React development, calling a hook inside a parent component causes the entire parent component (and all its children) to rerender whenever the hook's state changes.

By wrapping a custom hook with wrap or useHook, you create a wrapper component that:

  1. Calls the hook internally.
  2. Accepts hook arguments as props.
  3. Exposes a render prop to display the UI, localizing hook rerenders to the render callback rather than triggering a parent-level update.

See how it works here

Installation

pnpm add @bemedev/hook-wrapper
# or
npm install @bemedev/hook-wrapper
# or
yarn add @bemedev/hook-wrapper

Usage Example

1. Define a Custom Hook

import { useState } from 'react';

export const useCounter = ({ step = 1 }: { step?: number } = {}) => {
  const [count, setCount] = useState(0);
  return { count, inc: () => setCount(c => c + step) };
};

2. Wrap the Hook and Render It

import { wrap } from '@bemedev/hook-wrapper';
import { useCounter } from './useCounter';

// Wrap the hook to get a wrapper component
const CounterWrapper = wrap(useCounter);

export const Demo = () => {
  // The parent component (Demo) will render only ONCE.
  // Clicking the increment button will only rerender the children inside the CounterWrapper.
  return (
    <div>
      <h3>Parent Component (No Rerenders on Hook Change)</h3>

      <CounterWrapper
        step={5}
        render={({ count, inc }) => (
          <div>
            <p>Count: {count}</p>
            <button onClick={inc}>Increment by 5</button>
          </div>
        )}
      />
    </div>
  );
};

API Reference

wrap(hook) / useHook(hook)

Wraps a custom hook and returns a component that renders it (useHook is an alias of wrap).

Parameters

  • hook: The React hook function to wrap.

Returns

A React component that accepts:

  • Props matching the arguments of the wrapped hook.
  • A render function prop that receives the hook's return value and returns a React element.

wrap.noParams(hook, render)

Helper for wrapping hooks that accept no parameters. Returns a component function directly without requiring props at render time.

Parameters

  • hook: The parameterless React hook function to wrap.
  • render: A function receiving the hook's return value and returning a React element.

Returns

A parameterless React component function () => ReactNode.

License

MIT

Changelog

Read CHANGELOG.md for more details about the changes.

Author

chlbri ([email protected])

My GitHub