React Hot Toast 使用教程

React Hot Toast 使用教程

react-hot-toastSmoking Hot React Notifications 🔥 项目地址:https://gitcode.com/gh_mirrors/re/react-hot-toast

1. 项目的目录结构及介绍

React Hot Toast 项目的目录结构如下:

react-hot-toast/
├── assets/
├── github/workflows/
├── site/
├── src/
│   ├── core/
│   ├── hooks/
│   ├── index.tsx
│   ├── toast.tsx
│   ├── types.ts
│   ├── utils.ts
│   └── ...
├── test/
├── .gitignore
├── .npmrc
├── .prettierrc
├── .yarnrc
├── jest.config.js
├── LICENSE
├── package.json
├── pnpm-lock.yaml
├── README.md
├── tsconfig.json
├── tsup.config.ts
└── ...

目录介绍

  • assets/: 存放项目资源文件。
  • github/workflows/: 存放 GitHub Actions 的工作流配置文件。
  • site/: 存放项目文档和示例网站的文件。
  • src/: 项目的核心源代码文件夹,包含核心功能、钩子、入口文件、类型定义和工具函数等。
  • test/: 存放测试文件。
  • .gitignore: Git 忽略文件配置。
  • .npmrc: npm 配置文件。
  • .prettierrc: Prettier 代码格式化配置文件。
  • .yarnrc: Yarn 配置文件。
  • jest.config.js: Jest 测试框架配置文件。
  • LICENSE: 项目许可证文件。
  • package.json: 项目依赖和脚本配置文件。
  • pnpm-lock.yaml: pnpm 锁定文件。
  • README.md: 项目说明文档。
  • tsconfig.json: TypeScript 配置文件。
  • tsup.config.ts: tsup 打包工具配置文件。

2. 项目的启动文件介绍

React Hot Toast 的启动文件主要是 src/index.tsx,它是项目的入口文件,负责导出主要的功能和组件。

// src/index.tsx

export { Toaster } from './toast';
export { toast } from './core/toast';
export { useToaster } from './hooks/useToaster';
export * from './types';

启动文件介绍

  • Toaster: 负责渲染所有通知的组件。
  • toast: 触发通知的主要函数。
  • useToaster: 自定义钩子,用于管理通知。
  • types: 导出项目的类型定义。

3. 项目的配置文件介绍

React Hot Toast 的配置文件主要包括 package.jsontsconfig.jsontsup.config.ts

package.json

package.json 文件包含了项目的依赖、脚本和其他元数据。

{
  "name": "react-hot-toast",
  "version": "2.4.1",
  "description": "Smoking Hot React Notifications",
  "main": "dist/index.js",
  "module": "dist/index.esm.js",
  "types": "dist/index.d.ts",
  "scripts": {
    "build": "tsup",
    "test": "jest",
    "lint": "eslint src --ext .ts,.tsx",
    "format": "prettier --write \"src/**/*.{js,ts,tsx}\""
  },
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  },
  "devDependencies": {
    "@types/react": "^17.0.3",
    "@types/react-dom": "^17.0.3",
    "eslint": "^7.23.0",
    "jest": "^26.6.3",
    "prettier": "^2.2.1",
    "tsup": "^4.10.1",
    "typescript": "^4.2.3"
  },
  "peerDependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
}

tsconfig.json

tsconfig.json 文件是 TypeScript

react-hot-toastSmoking Hot React Notifications 🔥 项目地址:https://gitcode.com/gh_mirrors/re/react-hot-toast

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

袁耿浩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值