1.2.2 • Published 6 years ago

react-scaffold-jr v1.2.2

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

React-Scaffold

Simple CLI to create React Components using Container/Component/Styles pattern.

Includes

  • Redux
  • React-Router
  • React-Apollo

How To Install

  • npm install react-scaffold -g

How To Use

  • cd into the folder where your files are to be built
  • scaffold Bar

Options

  • Using the -d flag, you can specify a subfolder as the location
    • Use this option when you are in the root of your project
    • scaffold -d src/components/foo Bar

Sample Output

  • Bar.styles.js
export default theme => ({
})
  • BarComponent.js
import React, { Component } from 'react';
import {withStyles} from 'material-ui';
import styles from './YourComponentName.styles';

class Bar extends Component {

    render() {
        return (
            <div />
        )
    }
}

export default withStyles(styles, {withTheme: true})(Bar);
  • BarContainer.js
import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { compose, withApollo } from 'react-apollo';
import { withRouter } from 'react-router-dom';
import Bar from './BarComponent';

class BarContainer extends Component {
    render() {
    
        return (
            <Bar />
        )
    }
}

const mapStateToProps = state => (
    {
        store: state.BarReducer
    }
);

const mapDispatchToProps = dispatch => (
    bindActionCreators({},dispatch)
)

const enhancer = compose(
    withRouter,
    withApollo,
    connect(mapStateToProps, mapDispatchToProps)
  );

export default enhancer(Bar);