create-react-file

2.0.3 • Public • Published

create-react-file

Use command line to create component or something else

Installation

npm install create-react-file -g

Execution

$ create-react-file Component

Create folder ./Component and file Component.jsx, index.js, Component.css.

Component.jsx

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';

class Component extends Component {
  constructor(props) {
    super(props);
  }

  static propTypes = {};

  static defaultProps = {};

  state = {};

  render() {
    const { className, children, ...others } = this.props;

    const cls = classnames({
      'components-component-render': true,
      [className]: !!className,
    });

    return (
      <div className={cls} {...others}>
        { children }
      </div>
    );
  }
}

export default Component;

Component.scss

.components-component-render {
  
}

index.js

import './Component.scss';
import Component from './Component';

export default Component;

Help

$ create-react-file --help
  Usage: create-react-file [options] <name> [parentName]

  Options:
    -f, --function  create function component
    -p, --page      create component as page
    -s, --single    create single file Component.jsx
    -h, --hooks     create file hooks.js
    -h, --help      output usage information

Simply command-line

Little tip with oh my zsh. Changing .zshrc like this makes the tool be more convenient.

alias cf="create-react-file"
alias cfp="create-react-file -p"

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.31latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.31
2.0.2-alpha.50
2.0.2-alpha.40
2.0.2-alpha.30
2.0.2-alpha.20
2.0.2-alpha.10
2.0.20
2.0.10
2.0.00
1.1.281
1.1.270
1.1.260
1.1.250
1.1.240
1.1.230
1.1.220
1.1.210
1.1.200
1.1.190
1.1.180
1.1.170
1.1.160
1.1.150
1.1.140
1.1.130
1.1.120
1.1.110
1.1.100
1.1.90
1.1.80
1.1.70
1.1.60
1.1.50
1.1.40
1.1.30
1.1.20
1.1.10
1.1.00
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i create-react-file

Weekly Downloads

2

Version

2.0.3

License

ISC

Unpacked Size

29.6 kB

Total Files

35

Last publish

Collaborators

  • xiaoshuang