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

redux-store-setup

v1.0.2

Published

Simple Redux store setup CLI tool with count state

Downloads

200

Readme

Redux Store Setup CLI

redux-store-setup is a simple command-line tool that helps you quickly set up the basic structure of a Redux store for your React application. It generates folders and files for actions, reducers, and store configuration, making it easy to start managing state in your project.

Installation

You can install the package globally using npm:

npm install -g redux-store-setup

Usage

After installing the package, use the setup-store command to generate the Redux store structure in your project. You can specify the directory where you want the boilerplate to be created:

setup-store --directory src/redux

or use the shortened version:

setup-store -d src/redux

This command will generate the following structure in the directory you specify:

src/redux/
├── actions/
│   ├── actions.js
│   └── types.js
├── reducers/
│   ├── reducer.js
│   └── store.js

Example

If you run the command with the following:

setup-store --directory src/redux

The tool will create the folder src/redux/ with the following files:

  • actions/types.js: Defines action types such as COUNT.
  • actions/actions.js: Contains action creators like setCount().
  • reducers/reducer.js: Handles state changes based on actions.
  • reducers/store.js: Combines the reducers into a single root reducer.

How to Integrate

After generating the Redux setup files, you can integrate them into your React application.

  1. Configure the Store in Your Application:

In your main application file (e.g., src/index.js), you can import the generated store.js and integrate it with your app:

import { createStore } from 'redux';
import rootReducer from './redux/reducers/store';

const store = createStore(rootReducer);
  1. Use the Actions and Reducers:

You can dispatch actions and manage the state using the generated actions and reducers.

Example:

import { setCount } from './redux/actions/actions';

// Dispatch the action
store.dispatch(setCount(5));

// Get the updated state
console.log(store.getState().count);  // Output: 5

Structure Explanation

  • actions/types.js: Defines the constants used as action types (e.g., COUNT).
  • actions/actions.js: Contains the action creator setCount() for updating the count state.
  • reducers/reducer.js: Manages the state for count based on the dispatched action.
  • reducers/store.js: Combines all reducers into a single root reducer for the Redux store.

Example Redux Flow

  1. Dispatch an action using an action creator from actions/actions.js.
  2. The action type is matched in reducers/reducer.js.
  3. The state is updated accordingly and managed in the Redux store.

Credits

Created by Qasim Saeed

LinkedIn
GitHub

Offer Me a Coffee

If you like my work and want to support me, you can buy me a coffee!