create-react-redux-component

1.0.2 • Public • Published

Generate one or multiple boilerplate components within src with the following files:

src
├── components
    ├── <ComponentName>
        ├── index.js
        ├── <ComponentName>.js
        ├── <ComponentName>.css

Note: the scripts are bash scripts and may not run on Windows machines. If that is the case, use Git Bash.

Install

npm install -g create-react-redux-component

Example

create-react-redux-component Test

will create

src
├── components
    ├── Test
        ├── index.js
        ├── Test.js
        ├── Test.css

where the individual files look like the following:

index.js

import Test from './Test';
 
export default Test;

Test.css

/* empty */

Test.js

import React, { Component } from 'react';
import './Test.css';
// import { action } from './place';  // this is boilerplate for an action import; replace as needed
import { connect } from 'react-redux';
 
const mapStateToProps = state => {
  return { ...state };
};
 
const mapDispatchToProps = dispatch => {
  // the following is the boilerplate, replace 
  // with real actions as needed; don't forget
  // to import them!
  /*
  return {
    action: element => dispatch(action(element))
  }
  */
 
  return null; // delete this once the above is implemented
};
 
class ConnectedTest extends Component {
  render() {
    return <div>This is a component called Test.</div>;
  }
}
 
const Test = connect(
  mapStateToProps, 
  mapDispatchToProps
)(ConnectedTest);
 
export default Test;

License

MIT © Haldun Anil

Package Sidebar

Install

npm i create-react-redux-component

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

6.38 kB

Total Files

7

Last publish

Collaborators

  • haldunanil