@5calls/react-components 中文文档教程
5 Calls React Component Library
该存储库包含 5 Calls 项目中使用的标准 React 组件。
Project installation and Build
Install dependencies
使用以下命令从 npm 安装依赖项: 使用以下命令
npm install
Build this library
将库构建到 lib 文件夹中:
npm run build
Publish this library to npm
构建库,然后运行以下命令:
npm publish
确保在发布包更新之前在 package.json 中添加版本号。
在 npm 中发布模块后,您可以通过运行以下命令在另一个项目中使用此模块中的组件:
npm install --save @5calls/react-componets
Link this project to local npm
要设置一个 npm 链接,允许您在本地使用这些组件而无需安装 npm 包,请从该项目的根目录运行 以下命令文件夹:
npm link
如果对此项目进行了编辑,则无需重复运行 npm link
。 您只需运行构建即可使此代码中的任何更改可用于使用这些组件的项目。
Setup a local application to use linked components from this project
通过在项目的根文件夹中运行以下命令,将链接的项目引用到本地 React 应用程序:
npm link @5calls/react-components
要将此项目的组件添加到 React jsx 或 tsx 文件,请使用 ES2015 import 语句。 例如,要添加 Faq
组件,请使用以下导入:
import { Faq } from '@5calls/react-components';
TODOs
- Add more components
- Add local CSS styling
5 Calls React Component Library
This repository holds standard React components used in the 5 Calls project.
Project installation and Build
Install dependencies
Install dependencies from npm using the command:
npm install
Build this library
Build the library into the lib folder using:
npm run build
Publish this library to npm
Build the library and then run the following command:
npm publish
Make sure you bump the version number in package.json before you publish an update to the package.
Once the module is published in npm, you can use the components in this module in another project by running the following command:
npm install --save @5calls/react-componets
Link this project to local npm
To setup an npm link that allows you to use these components locally without installing the npm package run the following from this project's root folder:
npm link
There is no need to run npm link
repeatedly if an edit is made to this project. You just need to run the build to make any changes in this code available to a project that uses these components.
Setup a local application to use linked components from this project
Reference the linked project to a local React application by running the following in the project's root folder:
npm link @5calls/react-components
To add this project's components to a React jsx or tsx file use an ES2015 import statement. For instance to add the Faq
component use the following import:
import { Faq } from '@5calls/react-components';
TODOs
- Add more components
- Add local CSS styling