npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zxx_npm/create-react-component

v1.0.1

Published

一个用于快速生成 React 组件的命令行工具。当前版本支持:

Downloads

202

Readme

Create React Component

一个用于快速生成 React 组件的命令行工具。当前版本支持:

  • 生成普通组件和页面组件
  • 生成 jsx / tsx 入口文件
  • 生成 scss / less 模块化样式文件
  • 在普通组件创建时自动补全外层 index.ts 导出

安装

全局安装:

npm install -g @zxx_npm/create-react-component

临时执行:

npx @zxx_npm/create-react-component generate MyComponent

安装后会注册命令:

rcc

命令

rcc generate <componentName>

生成一个新的 React 组件目录。

别名:

rcc g <componentName>

选项

| 选项 | 说明 | | --- | --- | | -p, --page | 生成页面组件 | | -c, --component | 生成普通组件,默认行为 | | -t, --typescript | 生成 tsx / ts 文件 | | -j, --javascript | 生成 jsx / js 文件,默认行为 | | -s, --scss | 生成 index.module.scss | | -l, --less | 生成 index.module.less |

互斥规则:

  • --page--component 不能同时传
  • --typescript--javascript 不能同时传
  • --scss--less 不能同时传

组件名规则:

  • 只能以字母开头
  • 只能包含字母、数字、_-

用法示例

生成普通组件:

rcc generate MyComponent

生成 TypeScript 普通组件:

rcc generate MyComponent --typescript

生成带 scss 模块样式的普通组件:

rcc generate MyComponent --scss

生成带 less 模块样式的 TypeScript 页面组件:

rcc generate MyPage --page --typescript --less

生成结果

普通组件

命令:

rcc generate MyComponent --scss

生成目录:

MyComponent/
├── index.jsx
└── index.module.scss

生成的 index.jsx 会包含样式导入:

import React from 'react';
import styles from './index.module.scss';

export const MyComponent = () => {
    return (
        <div className={styles.container}>
            <h1>MyComponent</h1>
        </div>
    );
};

如果当前目录不存在 index.ts,工具会自动创建;存在则追加导出:

export * from './MyComponent';

页面组件

命令:

rcc generate MyPage --page --typescript --less

生成目录:

MyPage/
├── components/
│   └── index.ts
├── index.module.less
├── index.tsx
└── services/
    └── index.ts

其中页面入口会自动引入样式文件:

import React from 'react';
import styles from './index.module.less';

const MyPage = () => {
    return (
        <div className={styles.container}>
            <h1>MyPage</h1>
        </div>
    );
};

export default MyPage;

开发

构建命令:

npm run build

本地联调:

npm link
rcc --version