lore-generate-component

Generates a new React component in src/components

generate component

CLI command to add a Component to your project.

The component will be generated using the language preference specified in the .lorerc file of your project, and placed in the src/components folder.

Usage

lore generate component MyComponent

The command above create a file located at src/componnets/MyComponent.js that looks like this:

import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';

export default createReactClass({
  displayName: 'MyComponent',

  propTypes: {},

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

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 = {};

export default MyComponent;
import React from 'react';
import PropTypes from 'prop-types';

class MyComponent extends React.Component {

  static propTypes = {};

  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;