Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-create-action-index

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-create-action-index

Creates an ES6 ./index.js file within target directories that imports all action files and exports a single action object.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

redux-create-action-index

CLI utility to creates or update a index.js file in supplied target directories. The generated index file will import all sibling redux action files and export a single redux action object.

Installation

npm install --save-dev redux-create-action-index

Usage

redux-create-action-index ./src/actions

Example

Given the following directory structure:

> tree ./src/actions
./
├── file1.js
├── file2.js
├── file3.js
├── file4.js
└── file5.js

0 directories, 5 files

Running js redux-create-action-index ./src/actions will generate an index.js file in ./src/actions containing:

import * as file1Actions from './file1.js';
import * as file2Actions from './file2.js';
import * as file3Actions from './file3.js';
import * as file4Actions from './file4.js';
import * as file5Actions from './file5.js';

export default Object.assign({}, 
    file1Actions,
    file2Actions,
    file3Actions,
    file4Actions,
    file5Actions
);

These ActionCreators can now be accessed in any component using redux's connect via:

import {connect} from 'react-redux';
import ActionCreators from '../actions';

...

function mapDispatchToProps(dispatch) {
    return bindActionCreators(ActionCreators, dispatch);
}

...

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

CLI Options

  --indent, -i  set number of spaces to indent             [number] [default: 4]
  --suffix, -s  suffix to add to the import module name    [string] [default: "Actions"]
  --help        Show help                                  [boolean]

Keywords

FAQs

Package last updated on 02 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc