0.0.1 • Published 10 months ago

@hypermediocrity/react-component-generator v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

react-component-generator

React component generator

Install

Install globally

npm install -g

Example

Generate a component using the following command

rcg generate MyComponent

This will generate the following files

  • MyComponent.js
  • MyComponent.module.css

Options

You can view the available options as follows

rcg generate --help
OptionDescriptionDefault
-d, --directory Directory to place componentDirectory where command was issued
--subdirPlaces component into its own directory locationfalse

Example using -d or --directory

Generate a component using the following command

rcg generate MyComponent -d MyDirectory
rcg generate MyComponent --directory MyDirectory

This will generate the following files

  • MyDirectory
    • MyComponent.js
    • MyComponent.module.css

Example using -d and --subdir

Generate a component using the following command

rcg generate MyComponent -d MyDirectory --subdir

This will generate the following files

  • MyDirectory
    • MyComponent
      • index.js
      • MyComponent.js
      • MyComponent.module.css

index.js content

The contents of the index.js file are as follows

import MyComponent from './MyComponent';

export default MyComponent;

MyComponent.js content

The contents of the MyComponent.js file are as follows

import React from 'react';
import PropTypes from 'prop-types';

import styles from './MyComponent.module.css';

function MyComponent() {
  return (
    <div className={styles.container}>
      MyComponent
    </div>
  );
}

MyComponent.propTypes = {

};

MyComponent.defaultProps = {

};

export default MyComponent;

MyComponent.module.css content

The contents of the MyComponent.module.css file are as follows

.container {}

TODO

  • Make installable
  • Publish to npm
  • Additional options
    • No style
    • Typescript
0.0.1

10 months ago