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

redux-inst

v0.8.0

Published

Allows you to write a component once and reuse it an unlimited number of times! Just passing the "inst" parameter at the call location. The state of each instance will be independent.

Downloads

36

Readme

Redux-Inst

Allows you to write a component once and reuse it an unlimited number of times!
Just passing the "inst" parameter at the call location. The state of each instance will be independent.

Example of using a component based on Redux-Inst

Calling the same component, but with its own independent state.
It is very easy to re-use, there is no limit on the number of instances!

<MultiColoredButtonContainer inst="first"/>
<MultiColoredButtonContainer inst="second"/>

If you need to redefine the original state when creating an instance, it is also very simple.

<MultiColoredButtonContainer
    inst="second"
    initState={{
        someValue: "This instance has a different value",
    }}
/>

When re-render, initState is not overwritten, so as not to break the state every time. Only for initial creation!

How to create reused reducer

// MultiColoredButtonReducer.js

import { multiInitReducer } from "redux-inst";
import { MultiColoredButtonActionTypes } from "./MultiColoredButtonActionTypes";

let initState = {
    // inst: null, - This line is required
	inst: null,
	someValue: "",
};

const MultiColoredButtonReducer = () => {
    const componentName = "multiColoredButton";
    // multiInitReducer - converts shared Actions to individual Actions for this component,
    // and adds initState.
	let { actionTypes, getState } = multiInitReducer(
		MultiColoredButtonActionTypes,
		componentName,
		initState
	);

	return [
		componentName,
		initState,
		{
			[actionTypes.ON_SOME_ACTION]: (states, action) => {
                let { inst, value } = action.payload;
                // getState - retrieves the state of all component instances
                // and returns the state only for the current instance
				let state = getState(states, inst);

                // With immer under the hood, you can interact with your data by simply changing it,
                // while still retaining all the benefits of immutable data.
				state.someValue = value;
			},
		},
	];
};

export default MultiColoredButtonReducer;

Container for a reused component

import { connect } from "react-redux";
import { mapState } from "redux-inst";
import MultiColoredButtonActions from "./MultiColoredButtonActions";
import MultiColoredButton from "./MultiColoredButton";

// states - for all instances
const mapStateToProps = (states, ownProps) => {
    // mapState - returns the state for the current instance
	let state = mapState(states, "multiColoredButton", ownProps);

	return {
		someValue: state.someValue,
	};
};

const mapDispatchToProps = (dispatch, ownProps) => {
    // Retrieves the name of the current component instance
	let { inst } = ownProps;

	return {
		onSomeEvent: value => dispatch(MultiColoredButtonActions.onSomeEvent(inst, value)),
	};
};

export default connect(mapStateToProps, mapDispatchToProps)(MultiColoredButton);

Actions for a reused component

"ActionTypes" are used inside "Actions", they are as simple as possible, and then they will be automatically converted.

// MultiColoredButtonActionTypes.js

export const MultiColoredButtonActionTypes = {
	ON_SOME_ACTION: "ON_SOME_ACTION",
};
// MultiColoredButtonActions.js

import { createActions } from "redux-inst";
import { MultiColoredButtonActionTypes } from "./MultiColoredButtonActionTypes";

// Conversion for a component instance
const actionsType = createActions(MultiColoredButtonActionTypes, "MultiColoredButton");
const MultiColoredButtonActions = {
	onSomeEvent: (inst, value) => ({
		type: actionsType.ON_SOME_ACTION,
		payload: { inst, value },
	}),
};

export default MultiColoredButtonActions;

Connecting a new component after creating it in reducer

// reducers.js

export default combineReducers({
    // Pages or something else with the usual approach
    aboutPage: AboutPageReducer,
    
    // Reused components
	components: componentsReducers([
		MultiColoredButtonReducer,
	]),
});