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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-redux-human-hooks

v0.10.2

Published

React-Redux hooks for human beings

Downloads

8

Readme

React Redux Human Hooks

David npm bundle size NPM

React hooks for redux that humans can understand. Integrate redux into your React app one npm install away.

Introduction

The main goal of react-redux-human-hooks is that you can integrate Redux into your app in a simple and fast way, while maintaining performance.

Install

npm:

npm i react-redux-human-hooks

yarn:

yarn add react-redux-human-hooks

Usage

1. Create your actions

import {createAction,createActions} from  'react-redux-human-hooks';

//Define action types here
export  const { setAnimal, otherAction}
=  createActions('SET_ANIMAL','OTHER_ACTION')

//You can specify them one by one
export  const  setDog  =  createAction('SET_DOG');
  
//Or you can write your own actions creators
export  const  setSquanch  =  createAction('SET_SQUANCH',payload=>{
	//do something
	return  'Squanchy';
});

2. Create your reducer

import {createReducer} from  'react-redux-human-hooks'
import  *  as  actions  from  './actions';

const  reducer  =  createReducer({
	[actions.setAnimal]: (state, action) => ({
		...state,
		animal:  action.payload
	}),
	[actions.setDog]: (state, action) => ({
		...state,
		animal:  'Dog'
	}),
	[actions.setSquanch]: (state, action) => ({
		...state,
		animal:  'Squanchy'
	}),
	},
	//Initial state
	{
		animal:  'Cat',
	}
);

export  default  reducer;

3. Add Provider to your app

import  React  from  'react';

//We provide the necessary modules, you can also import them from redux and react-redux
import {Provider,createStore} from  'react-redux-human-hooks';

import  rootReducer  from  './reducer';
import  MyComponent  from  './MyComponent';

//Create the store, in this case we are using teh Redux Devtools middleware
const  store  =  createStore(rootReducer,
window.__REDUX_DEVTOOLS_EXTENSION__  &&
window.__REDUX_DEVTOOLS_EXTENSION__());

function  App() {
	return (
		//Note we are wrapping the entire app using Provider
		<Provider  store={store}>
			<div  className="App">
				<header  className="App-header">
					<h1>
						React Redux Human Hooks Example
					</h1>
				</header>
				<MyComponent/>
			</div>
		</Provider>
	);
}

export  default  App;

4. Use it in your components

import  React  from  'react';
import {useReduxState,useBindActionCreators} from  'react-redux-human-hooks';
import  *  as  actions  from  './actions';

function  MyComponent() {
	const {setDog,setAnimal,setSquanch} =  useBindActionCreators(actions);
	const {animal} =  useReduxState(
		state=>state
	)

	return (
		<div  style={{backgroundColor:'#F1F1F1',display:'flex',flexDirection:'column'}}>
			<h3>Animal: {animal}</h3>
			<div>
				<button  onClick={()=>setDog()}>Set Dog</button>
				<button  onClick={()=>setAnimal(Math.random()>0.5?'Cat':'Moose')}>Set Random</button>
				<button  onClick={()=>setSquanch()}>Set Squanch</button>
			</div>
		</div>
	);
}

export  default  MyComponent;