Skip to content

michaeltreyvaud/react-component-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-component-generator

React component generator

Install

Install globally

npm install -g @hypermediocrity/react-component-generator

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
Option Description Default
-d, --directory Directory to place component Directory where command was issued
--subdir Places component into its own directory location false

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

  • Additional options
    • No style
    • Typescript

About

React dummy component generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published