Formik-Effect 项目教程

Formik-Effect 项目教程

formik-effectDeclarative component for managing side-effects in Formik forms. 580 bytes项目地址:https://gitcode.com/gh_mirrors/fo/formik-effect

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

Formik-Effect 项目的目录结构如下:

formik-effect/
├── src/
│   ├── index.tsx
│   ├── Effect.tsx
│   ├── types.ts
│   ├── utils.ts
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── package-lock.json
├── package.json
├── rollup.config.js
├── tsconfig.json
├── tslint.json

目录结构介绍

  • src/: 包含项目的主要源代码文件。
    • index.tsx: 项目的入口文件。
    • Effect.tsx: 核心组件文件,用于处理 Formik 表单的副作用。
    • types.ts: 类型定义文件。
    • utils.ts: 工具函数文件。
  • .gitignore: Git 忽略文件配置。
  • .travis.yml: Travis CI 配置文件。
  • LICENSE: 项目许可证文件。
  • README.md: 项目说明文档。
  • package-lock.json: npm 依赖锁定文件。
  • package.json: 项目配置文件,包含依赖和脚本。
  • rollup.config.js: Rollup 打包配置文件。
  • tsconfig.json: TypeScript 配置文件。
  • tslint.json: TSLint 配置文件。

2. 项目的启动文件介绍

项目的启动文件是 src/index.tsx,它是整个项目的入口点。该文件主要负责导出 Effect 组件,以便其他项目可以使用。

// src/index.tsx
export { Effect } from './Effect';

3. 项目的配置文件介绍

package.json

package.json 文件包含了项目的元数据和依赖信息。以下是一些关键部分:

{
  "name": "formik-effect",
  "version": "1.0.0",
  "description": "Declarative component for managing side-effects in Formik forms",
  "main": "dist/index.js",
  "module": "dist/index.es.js",
  "scripts": {
    "build": "rollup -c",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "formik": "^2.2.6",
    "prop-types": "^15.7.2",
    "react": "^17.0.2"
  },
  "peerDependencies": {
    "formik": "^2.2.6",
    "react": "^17.0.2"
  },
  "devDependencies": {
    "@types/react": "^17.0.3",
    "rollup": "^2.42.4",
    "rollup-plugin-typescript2": "^0.30.0",
    "typescript": "^4.2.3"
  }
}

rollup.config.js

rollup.config.js 文件是 Rollup 的配置文件,用于打包项目。

import typescript from 'rollup-plugin-typescript2';

export default {
  input: 'src/index.tsx',
  output: [
    {
      file: 'dist/index.js',
      format: 'cjs',
    },
    {
      file: 'dist/index.es.js',
      format: 'es',
    },
  ],
  plugins: [
    typescript({
      tsconfig: 'tsconfig.json',
    }),
  ],
};

tsconfig.json

tsconfig.json 文件是 TypeScript 的配置文件,用于编译 TypeScript 代码。

{
  "compilerOptions": {
    "target": "es5",
    "module": "esnext",
    "jsx": "react",
    "outDir": "./dist",
    "strict": true,
    "esModuleInterop": true
  },
  "include": ["src"]
}

tslint.json

tslint.json 文件是

formik-effectDeclarative component for managing side-effects in Formik forms. 580 bytes项目地址:https://gitcode.com/gh_mirrors/fo/formik-effect

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

陆可鹃Joey

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

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

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

打赏作者

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

抵扣说明:

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

余额充值