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-claws

v1.0.2

Published

Semi-source-compatible React Hooks compatible layers.

Readme

React-Claws

A poor man's react-hooks.

Overview

React-Claws allow you to write your React Component using hooks where hooks isn't yet available, for example on React Native.

Requirement.

React 16+ (It uses new Context API).

How to use React-Claws

To define a component:

// ToggleButton.js
import withClaws from 'react-claws';
export default withClaws(({ useState }) => {

  return function ToggleButton({ titleA, titleB } => {
    const [count, setCount] = useState(false);
    const inc = () => setCount(count+1);
    return <button onClick={inc}>{`${inc}`}</button>
  })

}, 'StatedToggleButton'); // component name is optional

To define a claw(hook):

// useCounter.js
import { customClaw } from 'react-claws';
export default customClaw(({ useState }) => {

  return function useCounter(() => {
    const [count, setCount] = useState(false);
    const inc = ()=> setCount((count) => count+1);
    return [count, inc];
  });

});

Basically, what you write inside withClaws/customClaw is what you would write if you use react-hooks. You will also see that the standard hooks such as useState, are available and injected as argument to the block.

You have to return the component from the block. You also can only define one component per withClaws block. It's prefered to put one componet per file and use export default for each of them.

How it works.

React Claws create one extra HoC on wrapping your functional component. It then bind hooks-like named methods and inject into the block for your component.

Why Claws instead of standard React Component?

Hooks is simply easier to compose. It enables new way of thinking. So I think it's worth a shot to be able to write hooks like approach in older React environment.

Why Claws instead of recompose?

Level of nested component using recompose is just ridiculously high. Claws adds exactly one component HoC on top of your functional component, regardless of how many hooks you use, with the exception of nested Context.Consumer which is unavoidable.

WARNING: Claws probably will never be the same as hooks.

It is, first and foremost, my learning exercise done in a couple days. You may find some bug. I'm certain I haven't completely copied all behavior of a hook in some edge case. I may even misunderstand how some hooks are supposed to work. Bugs reports and contributions are welcomed.

Since it's just a simple wrapper over standard React. It may never be able to completely mimic what hooks can do. Still, from what I have tested so far you shouldn't see any obvious different.

Limitation.

  1. It uses HoC, so ref is not going to point to your functional component.
  2. useEffect currently works exactly at the same time as useLayoutEffect, in componentDidXXX. IMO, this is a minor behavior changes.
  3. I could use some help on adding debugging info. But I don't want to spend times on this unless people actually uses this library.
  4. Currently forWardRef to ref= props doesn't yet work. I think this is doable, though. Noted that forwardRef and useImperativeHandle still work if you pass it to a custom prop, say innerRef.
  5. useDebugValue doesn't work with the debugger, obviously. You can use chrome react inspector to inspect the state of the component. You will see array of states. (NOTES: Claws doesn't actually need or use this.state, but I set it to point to the internal register stack just so that's debugging/inspecting is possible.)
  6. My English is not the best. Contributions to correct any grammar mistakes are welcomed. Just be gentle :P