lore-generate-component

Generates a new React component in src/components

--router

Providing --router as an argument will generate a component configured for use with React Router.

Usage

lore generate component MyComponent --router
import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
import { Link, withRouter } from 'react-router';

export default withRouter(createReactClass({
  displayName: 'MyComponent',

  propTypes: {
    router: PropTypes.object.isRequired
  },

  render() {
    return (
      <div></div>
    );
  }
}));
import React from 'react';
import PropTypes from 'prop-types';
import { Link, withRouter } from 'react-router';

class MyComponent extends React.Component {

  constructor(props) {
    super(props);

    // Set your initial state here
    // this.setState = {};

    // Bind your custom methods so you can access the expected 'this'
    // this.myCustomMethod = this.myCustomMethod.bind(this);
  }

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

}

MyComponent.propTypes = {
  router: PropTypes.object.isRequired
};

export default withRouter(MyComponent);
import React from 'react';
import PropTypes from 'prop-types';
import { Link, withRouter } from 'react-router';

@withRouter
class MyComponent extends React.Component {

  static propTypes = {
    router: PropTypes.object.isRequired
  };

  constructor(props) {
    super(props);

    // Set your initial state here
    // this.setState = {};

    // Bind your custom methods so you can access the expected 'this'
    // this.myCustomMethod = this.myCustomMethod.bind(this);
  }

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

}

export default MyComponent;