# generate-react-ts

> Generate a react typescript component or stores with CLI

Latest version **0.0.2** (published 2018-07-12) · MIT license · 0 weekly downloads

## Install

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

Provides the command `grts`.

## 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.0.2 |
| Published | 2018-07-12 |
| First published | 2018-07-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 18 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | albertarvesu |
| Maintainers | albertarvesu |

## Links

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

## Dependencies (3)

- [fs-extra](https://npm.io/package/fs-extra.md) ^6.0.1
- [commander](https://npm.io/package/commander.md) ^2.16.0
- [replace-in-file](https://npm.io/package/replace-in-file.md) ^3.4.0

## Recent versions

- 0.0.2 (latest) — 2018-07-12
- 0.0.1 — 2018-07-12

## README

# generate-react-ts

An opinionated CLI generator for ReactJS components using Typescript for static typing and Enzyme for testing inspired by https://github.com/jonexiu/generate-react-component

This CLI should speed up the creation of React component including the test file using primarily using enzyme. It also include the option to create either class or pure component.

Class Component:

```javascript
import * as React from 'react';

interface ComponentProps {

}

interface ComponentState {

}

export class Component extends React.Component<ComponentProps, ComponentState> {
  constructor(props: ComponentProps) {

  }

  componentDidMount() {

  }

  public render() {
    return (
      <div></div>
    );
  }
}

export default Component;
```

Pure Component:

```javascript
import * as React from 'react';

interface ComponentProps {

}

export const Component = ({ }: ComponentProps) => (
  <div></div>
);
```

Test file

```javascript
import * as React from 'react';
import { shallow } from 'enzyme';

import { Component } from './Component';

it('renders the <Component /> without crashing', () => {
  const wrapper = shallow(<Component />);
  expect(wrapper.type()).not.toBeNull();
});
```

## Installation

Run

```yarn add -D generate-react-ts```

or

```npm --save-dev generate-react-ts```


##Usage

### Generate Class Component

Run

```grts <ComponentName>```

By default this will create React class component with Typescript syntax.

<br>

### Generate Pure Function Component

Run

```grts <ComponentName> --pure```

or

```grts <ComponentName> -p```

Create pure function component with typescript syntax.

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