https://github.com/piyush-bhatt/generate-component-react
CLI generator for ReactJS components based on specified name and options.
https://github.com/piyush-bhatt/generate-component-react
cli-generator component javascript react reactjs reactjs-components
Last synced: about 1 month ago
JSON representation
CLI generator for ReactJS components based on specified name and options.
- Host: GitHub
- URL: https://github.com/piyush-bhatt/generate-component-react
- Owner: piyush-bhatt
- License: mit
- Created: 2019-11-26T15:53:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-26T17:41:02.000Z (over 6 years ago)
- Last Synced: 2025-02-20T08:12:41.174Z (over 1 year ago)
- Topics: cli-generator, component, javascript, react, reactjs, reactjs-components
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/generate-component-react
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: License.md
Awesome Lists containing this project
README
# generate-component-react
generate-component-react is a CLI generator for ReactJS components based on specified name and options.
## Content
* [Installation](#installation)
* [Usage](#usage)
* [Functional Component](#functional-component)
* [Class Based Component](#class-based-component)
* [Options](#options)
* [Examples](#examples)
* [Contributing](#contributing)
* [License](#license)
## Installation
Use the package manager [npm](https://www.npmjs.com/) to install
```bash
npm install -g generate-component-react
```
## Usage
Make sure to execute the commands from your app root directory
### Functional Component
```bash
generate component -f
```
or
```bash
gc --function
```
### Class Based Component
```bash
generate component -c
```
or
```bash
gc --class
```
### Options
Following options can be used optionally,
**--css** : add a CSS module for the generated component, e.g.,
```bash
generate component --class --css
```
**-s** or **--state** : add state to the generated component, e.g.,
```bash
generate component --class --state
```
## Examples
* Sample component (functional component with state and css):
```bash
generate component sample --function --css --state
CREATED \src\sample\sample.css
CREATED \src\sample\sample.js
CREATED \src\sample\index.js
```
* Sample component (class based component without state but with css):
```bash
generate component sample --class --css
CREATED \src\sample\sample.css
CREATED \src\sample\sample.js
CREATED \src\sample\index.js
```
* Sample component (functional component in nested directory without state and css):
```bash
generate component components/sample --function
CREATED \src\components\sample\sample.js
CREATED \src\components\sample\index.js
```
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)