# generate-react-component

> Generate a react component with CLI

Latest version **0.1.6** (published 2017-03-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install generate-react-component
pnpm add generate-react-component
yarn add generate-react-component
bun add generate-react-component
```

Provides the command `rcmp`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2017-03-05 |
| First published | 2017-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Ed Lee |
| Maintainers | jonexiu |

## Links

- npm: https://www.npmjs.com/package/generate-react-component
- Repository: https://github.com/jonexiu/generate-react-component
- Homepage: https://github.com/jonexiu/generate-react-component#readme
- Issues: https://github.com/jonexiu/generate-react-component/issues
- npm.io page: https://npm.io/package/generate-react-component

## Dependencies (3)

- [program](https://npm.io/package/program.md) ^0.0.0-12
- [fs-extra](https://npm.io/package/fs-extra.md) ^2.0.0
- [commander](https://npm.io/package/commander.md) ^2.9.0

## Recent versions

- 0.1.6 (latest) — 2017-03-05
- 0.1.5 — 2017-02-16
- 0.1.4 — 2017-02-15
- 0.1.2 — 2017-02-15
- 0.1.1 — 2017-02-15
- 0.1.0 — 2017-02-15

## README

# generate-react-component

An opinionated CLI generator for ReactJS components.
<br>

## Why?

As a ReactJS developer, from time to time, I have to create components of same structure, by manual copy & paste. It is a time consuming no-brainer process that any React dev may repeat everyday. 

Typically, there are two kinds of components: [Functional and Class Components](https://facebook.github.io/react/docs/components-and-props.html#functional-and-class-components), the basic structure of either could always look the same, in one project:

Functional Component:

```javascript
import React from 'react'

const Cmp = (props) => {
  return (
    <div className={s.cover} style={bgStyle} >
    </div>
  )
}

export default Cover
```  

Class Component:

```javascript
import React, { Component } from 'react'

class Cmp extends Component {
    componentDidMount() {
    }
    render() {
        return (
        )
    }
}

export default Cmp  
```

It should be a super easy tool to automatically generate these files, without manual new file creation or copy & paste. So, here you are.
<br>

## Install

Run

```npm install -g generate-react-component```

You may need to ```sudo``` it.

<br>
## Usage

### Generate Class Component

Run

```rcmp <ComponentName>```

This will create a folder of your component name, and a **Class Component** js file with the same name.

<br>

### Generate Pure Function Component

Run

```rcmp <ComponentName> --pure```

or

```rcmp <ComponentName> -p```

This will create a folder of your component name, and **Pure Function Component** js file of the same name.

<br>
### Generate Component (Class or Pure) with a CSS file

Run

```rcmp <ComponentName> --pure --css```

or

```rcmp <ComponentName> -p -c```

This will create a folder of your component name, and component (Functional if ```--pure```) js file of the same name, and a css file of the same name.

<br>
That's it!

Enjoy and feel free to share your suggestion!

###TODO

- [ ] Add ```yarn add global```support
- [ ] Add Chalk fancy colors

---
_Source: https://npm.io/package/generate-react-component · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
