@hypermediocrity/react-component-generator
v0.0.1
Published
React component generator
Downloads
5
Readme
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
| 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
- MyComponent
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