1.0.5 • Published 7 years ago

create-reactredux v1.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

create-reactredux

Create New React and Redux Components Quickly

  • Requirements: src folder in the root of your directory where your React and Redux files are housed.
  • Setup: 1) npm install create-reactredux or yarn add create-reactredux 2) In your package.json create a new script like this

     ```
     "scripts": {
       "generate": "create-reactredux"
     }
     ```
     Or
     ```
        "scripts": {
          "generate": "node node_modules/create-reactredux/index.js"
        }
     ```

    3) To create a new component npm run generate YourComponentName

    4) This will create a new folder in your src folder with the same name. Inside you will find a new stateful React file setup and ready to go. Along with a Redux Container that has also been preconfigured.

      ```javascript
         import React, { Component } from 'react' 
    
         class Home extends Component {
           constructor(props) {
             super(props)
             this.state = {}
           }
    
           render() {
             return (
               <div></div>
             )
           }
         }
    
          export default Home 
        ```
        
        ```javascript
           import { connect } from react-redux
           import Home from './Home'
    
           const mapStateToProps = (state) => {
             return state
           }
    
           export default connect(mapStateToProps, null)(Home)
        ```
     

    5) If you wish to create a stateless component and associated Redux container add the argument "dumb" like so:

     ```npm run generate YourComponentName dumb```
     
     ```javascript
     import React from 'react'
    
     export const Test = (props) => {
       return(
         <div></div>
       )
     }
     ```
     
     ```javascript
     import { connect } from react-redux
     import { Test } from './Test'
    
     const mapStateToProps = (state) => {
       return state
     }
    
     export default connect(mapStateToProps, null)(Test)
     
     ```
     
     
    Contact

    If you have any further suggestions please contact me or submit a PR. If there is demand for a associated test file to be created I'm more than willing to make that happen.

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago