Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

generate-cli-react

dmytroivanishin71ISC1.1.0TypeScript support: included

A simple React CLI for generating components.

generate-react, generate-react-cli, react cli, cli, generate react component, generate component, react component, generate, component, build tools, react

readme

Generate React CLI

This tool provides fast creating React components and gets rid of copying, pasting and renaming files.

Installation

  npm install generate-cli-react --save-dev

Usage

This command create a folder with your component within default directory.

  npx generate-react component Box

You can also generate a few components at once.

  npx generate-react component Box Card Button

Example of the component files structure by default:

|-- /src
    |-- /components
        |-- /Box
            |-- Box.js
            |-- index.js

Options

You can also overwrite default options.

  npx generate-react component Box --withStyle --usePreprocessor scss

Example of the component files structure with options above:

|-- /src
    |-- /components
        |-- /Box
            |-- Box.js
            |-- Box.scss
            |-- index.js
Options Description Value Type Default Value
--path The path where you want the component to be generated. String ./src/components
--withStyle Creates a stylesheet file with this component. Boolean false
--useTypescript Creates the typescript component. Boolean false
--usePreprocessor Creates a stylesheet file used a preprocessor such as scss with this component. String ""
--useTest Creates test file with library enzyme or testingLibrary with this component. String ""