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

hooks-reducer

v2.0.6

Published

Use Redux in React Hooks.

Readme

Why

Your may like use Redux to manage and share a global state in your Application, but you also like to use React-hooks. hooks-reducer let you keep Redux programming mode. so you can easy to switch React.Component and Redux to React-hooks and hooks-reducer.

feature

  • Use with React hooks.
  • Global state in Application.
  • Share state to any descendant component.
  • Keep Redux programming mode, easy to update for old application.

Usage

Inject store to your Application.

import {HooksProvider} from 'hooks-reducer';
import rootReducer from './yourConfigs/rootReducer.js';

const store = rootReducer;

function App() {

    return (
        <HooksProvider hooksStore={store}>
            <MyComponent/>
        </HooksProvider>
    )
}

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

Use mergeReducer to combine your reducers.

import {mergeReducer} from 'hooks-reducer';
import * as reducerFoo from './pageFoo/reducerFoo.js';
import * as reducerBar from './pageBar/reducerBar.js';

const rootReducer = mergeReducer({
    reducerFoo,
    reducerBar
});

export default rootReducer;

Connect your component and hooks-reducer, get state and action.

import {useEffect} from 'react';
import {connect} from 'hooks-reducer';

const enhancedAction = (data) => (state, dispatch) => {
    // request service or do some other things...
    dispatch({type: 'enhancedAction', data: data});
};

const generalAction = (data) =>
    ({type: 'enhancedAction', data: data});

function Component(props) {
    const [state, dispatch] = props.reducer;
    // Get your state in props.reducer;
    // Don`t recommend you use dispatch, should use action instead.

    const {generalAction, enhancedAction} = props.actions;
    // Get your actions in props.actions;

    useEffect(() => {
        enhancedAction('Any type of data');
    }, []);

    console.log('My state: ', state);

    return (
        <div>
            Hello world!
            <button onClick={generalAction.bind(null, 'Any type of data')}>
                Action now!
            </button>
        </div>
    )
}

const MyComponent = connect(
    Component,
    'reducer', // Define your reducer key name in props
    {
        enhancedAction,
        generalAction
        // Define more action...
    },
    'actions' // Define your actions key name in props
);

export default MyComponent;

Example of reducer:

const initialState = {
    data: ''// Any type of data.
};

function reducerBar(state=initialState, action) {
    switch (action.type) {
        case 'updateData':
            return {...state, data: action.data};
        case 'resetData':
            return initialState;
        default:
            return state;
    }
}

export default reducerBar;