@innoways/hooks 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +171 -0
- package/README.md +162 -0
- package/build-info/index.stats.html +2648 -0
- package/dist/index.js +1279 -0
- package/package.json +45 -0
- package/rollup.config.js +13 -0
- package/tsconfig.dist.json +7 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Initial version
|
|
8
|
+
|
|
9
|
+
## 2.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- Initial changelog
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @jdfed/utils@2.0.0
|
|
19
|
+
|
|
20
|
+
## 1.0.0
|
|
21
|
+
|
|
22
|
+
### Major Changes
|
|
23
|
+
|
|
24
|
+
- Initial changelog
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @jdfed/utils@1.0.0
|
|
30
|
+
|
|
31
|
+
All notable changes to this project will be documented in this file.
|
|
32
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
33
|
+
|
|
34
|
+
### [0.8.2](https://github.com/jdfed/drip-form/compare/v0.8.1...v0.8.2) (2022-07-15)
|
|
35
|
+
|
|
36
|
+
**Note:** Version bump only for package @jdfed/hooks
|
|
37
|
+
|
|
38
|
+
### [0.8.1](https://github.com/jdfed/drip-form/compare/v0.8.0...v0.8.1) (2022-06-29)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @jdfed/hooks
|
|
41
|
+
|
|
42
|
+
## [0.8.0](https://github.com/jdfed/drip-form/compare/v0.7.0...v0.8.0) (2022-06-01)
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
- **form:** array container supports sorting ([#206](https://github.com/jdfed/drip-form/issues/206)) ([7a60b0b](https://github.com/jdfed/drip-form/commit/7a60b0b3e2eb9af8d6b479356ceee659bba86947))
|
|
47
|
+
- **generator:** delete element automatically selects the neighboring previous element or the parent ([945196a](https://github.com/jdfed/drip-form/commit/945196ab0903b6b5276a6630df7c89d6ca8b1cb1))
|
|
48
|
+
|
|
49
|
+
## [0.7.0](https://github.com/jdfed/drip-form/compare/v0.6.0...v0.7.0) (2022-03-14)
|
|
50
|
+
|
|
51
|
+
### Features
|
|
52
|
+
|
|
53
|
+
- **generator:** datepicker add default configuration ([a238424](https://github.com/jdfed/drip-form/commit/a238424c1aed9382735d1e2de1ec60890dd851c4))
|
|
54
|
+
- unitedSchema JSON add requiredMode configuration ([#150](https://github.com/jdfed/drip-form/issues/150)) ([7e717ef](https://github.com/jdfed/drip-form/commit/7e717ef9431228809fd5f2d3908a274f181225ec))
|
|
55
|
+
- **generator:** support change fieldKey in the property configuration panel ([#144](https://github.com/jdfed/drip-form/issues/144)) ([9681f62](https://github.com/jdfed/drip-form/commit/9681f62083c8c4feba7c4b1538b3ae99838545a3))
|
|
56
|
+
- onValidate prop support submit type ([#143](https://github.com/jdfed/drip-form/issues/143)) ([ceae921](https://github.com/jdfed/drip-form/commit/ceae921b42ea239b1b8833d4ff2e51aef627d42a))
|
|
57
|
+
|
|
58
|
+
### style
|
|
59
|
+
|
|
60
|
+
- **generator:** update objectContainer default style ([#154](https://github.com/jdfed/drip-form/issues/154)) ([d1590df](https://github.com/jdfed/drip-form/commit/d1590df17c8fbd003f29af800b6cfde091bf081a))
|
|
61
|
+
|
|
62
|
+
## [0.6.0](https://github.com/jdfed/drip-form/compare/v0.5.0...v0.6.0) (2022-01-24)
|
|
63
|
+
|
|
64
|
+
### Features
|
|
65
|
+
|
|
66
|
+
- 表单布局支持配置外边距 ([2016881](https://github.com/jdfed/drip-form/commit/201688140cebb2403899acca0ca58000dba7aaa3))
|
|
67
|
+
|
|
68
|
+
### Bug Fixes
|
|
69
|
+
|
|
70
|
+
- 修复数组子项为空,当前项自动被删除问题 ([#128](https://github.com/jdfed/drip-form/issues/128)) ([5c8e66b](https://github.com/jdfed/drip-form/commit/5c8e66bdda52db461d76e00456d95ded5ee2883e))
|
|
71
|
+
- 数组容器点击删除未删除错误内容 ([ce11e27](https://github.com/jdfed/drip-form/commit/ce11e273ab35ad8538990db90bb77000a059fc1b))
|
|
72
|
+
|
|
73
|
+
## [0.5.0](https://github.com/jdfed/drip-form/compare/v0.4.0...v0.5.0) (2022-01-13)
|
|
74
|
+
|
|
75
|
+
### Features
|
|
76
|
+
|
|
77
|
+
- setError 支持配置 action.ignore ([#125](https://github.com/jdfed/drip-form/issues/125)) ([b84aa5e](https://github.com/jdfed/drip-form/commit/b84aa5eead2b3f384d70bb45ce2961fcb1afbd1d))
|
|
78
|
+
|
|
79
|
+
## 0.4.0 (2022-01-11)
|
|
80
|
+
|
|
81
|
+
### Bug Fixes
|
|
82
|
+
|
|
83
|
+
- provide a default key for dynamic children ([#53](https://github.com/jdfed/drip-form/issues/53)) ([3abe606](https://github.com/jdfed/drip-form/commit/3abe6068e20d2d567426eb7ee637e2b6a0c93af5))
|
|
84
|
+
- upload preview error ([#83](https://github.com/jdfed/drip-form/issues/83)) ([fab9052](https://github.com/jdfed/drip-form/commit/fab90527dbedca35cc2119bca93106f9fa58ee28))
|
|
85
|
+
|
|
86
|
+
## 0.3.0 (2022-01-11)
|
|
87
|
+
|
|
88
|
+
### Bug Fixes
|
|
89
|
+
|
|
90
|
+
- provide a default key for dynamic children ([#53](https://github.com/jdfed/drip-form/issues/53)) ([3abe606](https://github.com/jdfed/drip-form/commit/3abe6068e20d2d567426eb7ee637e2b6a0c93af5))
|
|
91
|
+
- upload preview error ([#83](https://github.com/jdfed/drip-form/issues/83)) ([fab9052](https://github.com/jdfed/drip-form/commit/fab90527dbedca35cc2119bca93106f9fa58ee28))
|
|
92
|
+
|
|
93
|
+
## 0.2.0 (2022-01-07)
|
|
94
|
+
|
|
95
|
+
### Bug Fixes
|
|
96
|
+
|
|
97
|
+
- provide a default key for dynamic children ([#53](https://github.com/jdfed/drip-form/issues/53)) ([3abe606](https://github.com/jdfed/drip-form/commit/3abe6068e20d2d567426eb7ee637e2b6a0c93af5))
|
|
98
|
+
- upload preview error ([#83](https://github.com/jdfed/drip-form/issues/83)) ([fab9052](https://github.com/jdfed/drip-form/commit/fab90527dbedca35cc2119bca93106f9fa58ee28))
|
|
99
|
+
|
|
100
|
+
**Note:** Version bump only for package @jdfed/hooks
|
|
101
|
+
|
|
102
|
+
## 0.1.0 (2021-11-24)
|
|
103
|
+
|
|
104
|
+
### Features
|
|
105
|
+
|
|
106
|
+
- 表单联动升级 ([e77c5cd](https://github.com/jdfed/drip-form/commit/e77c5cda7e7f89dcab9b624f2e81a95f15412bee))
|
|
107
|
+
- 表单支持异步校验 ([8a50889](https://github.com/jdfed/drip-form/commit/8a50889e6ce05977308c76d2daf9f18408c4f8e3))
|
|
108
|
+
- 打包&文档 ([a65b57e](https://github.com/jdfed/drip-form/commit/a65b57e1fa390dc38d1bd3d9a5cb2c98f446744f))
|
|
109
|
+
- 迁移 babel-form 至 drip-form ([7687505](https://github.com/jdfed/drip-form/commit/768750518a8fdd9de93234fb8fbd5fc1cbd555b6))
|
|
110
|
+
- 嵌套表单 ([b939eed](https://github.com/jdfed/drip-form/commit/b939eed9bf23db5efa9a6c8177a24b397f4e8ba8))
|
|
111
|
+
- 嵌套对象必填支持&useQuery 支持 getkey ([d33a002](https://github.com/jdfed/drip-form/commit/d33a002567c7061ee28f5063738cba71c53872bf))
|
|
112
|
+
- 删除 Spin loading ([1a6d7df](https://github.com/jdfed/drip-form/commit/1a6d7df9e638d49bb3b938c2bbc46fb274bb6ea3))
|
|
113
|
+
- 升级 ajv ([1708e2c](https://github.com/jdfed/drip-form/commit/1708e2c8ad8581a78be9923f194c494e2f970a4c))
|
|
114
|
+
- 添加 combine & 修复 addField 类型引用错误的问题 ([cd5fb7d](https://github.com/jdfed/drip-form/commit/cd5fb7d73704739073f734dcd1ca384299ba2f67))
|
|
115
|
+
- 拖拽优化 ([90e2251](https://github.com/jdfed/drip-form/commit/90e22517082fe2a432bb443fc1961451da7b2ba0))
|
|
116
|
+
- 修改 hooks ([9072713](https://github.com/jdfed/drip-form/commit/90727133557293e4a31d43470c2549b54b0a38d2))
|
|
117
|
+
- 隐藏表单(未加载表单)不校验 ([d57c264](https://github.com/jdfed/drip-form/commit/d57c264eb1bab35c7269445def82169e0ee73cf7))
|
|
118
|
+
- 支持拖拽 ([45bba5c](https://github.com/jdfed/drip-form/commit/45bba5c4f75a268b06310105b6865bb42f3eca39))
|
|
119
|
+
- 支持校验文案配置 ([58adade](https://github.com/jdfed/drip-form/commit/58adadebdb12233bd961ef5a0937240893b9eb5f))
|
|
120
|
+
- 支持业务组件 ([eb9dc7d](https://github.com/jdfed/drip-form/commit/eb9dc7dafdd78ebb2fbbc375d73b0530b066b6e3))
|
|
121
|
+
- **generator:** 支持校验 ([93367c5](https://github.com/jdfed/drip-form/commit/93367c5d965007638b51653459f1faeff9d637c5))
|
|
122
|
+
- **generator:** 支持校验联动 ([ed519f5](https://github.com/jdfed/drip-form/commit/ed519f559ea5ceb0524787f6a8e343fbe845024b))
|
|
123
|
+
- 异步校验 loading 态 ([6efb51a](https://github.com/jdfed/drip-form/commit/6efb51ad5f75a4a14b41a7b460eb51438d6807f2))
|
|
124
|
+
- 支持 select+text 组合组件 ([1c7b3c7](https://github.com/jdfed/drip-form/commit/1c7b3c78046c7b2a4397980e7712035c6d450707))
|
|
125
|
+
- 支持 set、get、merge ([dc267b6](https://github.com/jdfed/drip-form/commit/dc267b6a23d7d9a8b5bf3edff303adfed7a98056))
|
|
126
|
+
- **schema 升级:** uiSchema 中 onChange 和 vcontrol 支持函数占位符 ([1225238](https://github.com/jdfed/drip-form/commit/122523861064dee2fa4a5e077a0d41bf5c76f1fe))
|
|
127
|
+
- 支持 ts ([9afcd3a](https://github.com/jdfed/drip-form/commit/9afcd3ae3d4f4407f2bd4347bc1e182bee0ccbb8))
|
|
128
|
+
- antd 支持 treeselect 组件 ([6348f68](https://github.com/jdfed/drip-form/commit/6348f68e4292abf91a410c839376b98cd85f05bb))
|
|
129
|
+
- babel-form 初始化 ([51fd2af](https://github.com/jdfed/drip-form/commit/51fd2af04a66c1d84970a8060174e20b0d859746))
|
|
130
|
+
- merge master ([1f5d45c](https://github.com/jdfed/drip-form/commit/1f5d45ce1cdd7b86a80cd049631eb9d46a6310e7))
|
|
131
|
+
- text 表单添加禁止输入字段 disabled_input ([6ea4b33](https://github.com/jdfed/drip-form/commit/6ea4b330d99b9331975fdc6a7c93dec55c39c199))
|
|
132
|
+
- treeselect 组件支持数据包含父级 id ([7de8fb2](https://github.com/jdfed/drip-form/commit/7de8fb2eef59175babb7aabef8fec2ba8b64d4b4))
|
|
133
|
+
- upload 支持 maxFileNumber 和 customUpload ([54c3611](https://github.com/jdfed/drip-form/commit/54c361148e66e65ea0ec505b2bf6cb059048eba2))
|
|
134
|
+
|
|
135
|
+
### Bug Fixes
|
|
136
|
+
|
|
137
|
+
- 必填校验失效 ([393e65a](https://github.com/jdfed/drip-form/commit/393e65a964594430a5f856e6cbba605cbe414693))
|
|
138
|
+
- 表单 value 为空自动删除 formdata 字段 ([b95f55f](https://github.com/jdfed/drip-form/commit/b95f55fad1260ed6ab69e62f4bd8376d89c925e2))
|
|
139
|
+
- 调整 useField 的判断条件,增加 fieldData 作为兜底取值,避免 e 取不到或者为 bool 的问题 ([6e5cba2](https://github.com/jdfed/drip-form/commit/6e5cba2f77f1f34e81ef2d7f96125e8c92587a86))
|
|
140
|
+
- 添加校验状态 ([e7ebc21](https://github.com/jdfed/drip-form/commit/e7ebc21b1805bcfb0b489bd23e1b07cba92e5672))
|
|
141
|
+
- 拖拽 fieldKey 会变化 ([55d84af](https://github.com/jdfed/drip-form/commit/55d84af09dad8ffa574a1e18d7db4a364e716e56))
|
|
142
|
+
- 修复导出包无法被 vite 或 snowpack 使用的问题 ([37f6636](https://github.com/jdfed/drip-form/commit/37f6636124ecd3223eac7152fb19a4accf2c5ca8))
|
|
143
|
+
- 修复每个 DripForm 无法使用独立 Ajv 校验的问题 ([d4c4988](https://github.com/jdfed/drip-form/commit/d4c4988c0eb530c285a82072272af9ba77446cfd))
|
|
144
|
+
- 修复图片上传不合理格式化的问题 & 所有包添加 unlink ([06f6f61](https://github.com/jdfed/drip-form/commit/06f6f61515828c7bcf1718f3d5118a72ca750a93))
|
|
145
|
+
- 修复未知 key ([c52556c](https://github.com/jdfed/drip-form/commit/c52556c17d71fe7f838578331d6627a9691fc230))
|
|
146
|
+
- 修复颜色选择器不支持透明度时 fieldData 异常问题 ([494b67c](https://github.com/jdfed/drip-form/commit/494b67ce34cc5b94476e7b1507cfc102dbace5b3))
|
|
147
|
+
- 修复一系列问题 ([52d3e42](https://github.com/jdfed/drip-form/commit/52d3e4258f962958189f1c8ced9b8c20dcf24653))
|
|
148
|
+
- 修复 exports 被删除后无法打包的问题 ([9d54151](https://github.com/jdfed/drip-form/commit/9d54151a8445fd0b7849b1ce2f806f4db8ef07a1))
|
|
149
|
+
- 修复 switch 组件始终为 true 的问题 ([a11e03a](https://github.com/jdfed/drip-form/commit/a11e03a2bdf588f1bd86fc4f515c4dd21f51b94f))
|
|
150
|
+
- 修复 typePath 没有动态更新,而是一直采用初始化状态的问题 ([c68beec](https://github.com/jdfed/drip-form/commit/c68beecdd5b1c7df3096a4dae01e2bcac560925d))
|
|
151
|
+
- 修复 typePath 没有动态生成的问题 ([f338118](https://github.com/jdfed/drip-form/commit/f338118011f394e74975a73d09f7168ef4e7692a))
|
|
152
|
+
- 修复 useAddField 丢失 cb 类型 ([da74ca4](https://github.com/jdfed/drip-form/commit/da74ca44a10ecea064aacd4cf2cef9d7f46a0e3d))
|
|
153
|
+
- 修复 usefield 删除校验状态异常&number 为 0 非空判断 ([242d503](https://github.com/jdfed/drip-form/commit/242d50319875eb007440e36800e08158aef8022b))
|
|
154
|
+
- 一系列问题 ([52f612a](https://github.com/jdfed/drip-form/commit/52f612a37c20c55ae5957365aa249e9ffff96db3))
|
|
155
|
+
- 移除多余 console & 调整代码结构 ([bc17f1a](https://github.com/jdfed/drip-form/commit/bc17f1aca8e9e5dfdbca23ea01d51af869dfd056))
|
|
156
|
+
- 异步校验 ([e373adc](https://github.com/jdfed/drip-form/commit/e373adc96638776053c33e231415029e509777d8))
|
|
157
|
+
- 异步校验数据获取 ([130331b](https://github.com/jdfed/drip-form/commit/130331b8f7c98bc9c5eb34057146216783df82d0))
|
|
158
|
+
- 组件渲染和 formData 生成的顺序问题以及 checkbox 全不选时的默认值问题 #C2020092276661 ([b2fbe15](https://github.com/jdfed/drip-form/commit/b2fbe15e5719a8c3a3de5ba7264ce5efe847a7c1)), closes [#C2020092276661](https://github.com/jdfed/drip-form/issues/C2020092276661)
|
|
159
|
+
- loading ([a724a19](https://github.com/jdfed/drip-form/commit/a724a19b1f085d3cf5d14de2ed3d145ddada4f5c))
|
|
160
|
+
- radio checkbox 支持问题 ([46110f4](https://github.com/jdfed/drip-form/commit/46110f4a5ffc2149bdadbaa1c0fffb72e3a9d410))
|
|
161
|
+
- radio 或 checkbox 的 value 是空字符串时,formData 未拿到数据 #C2021012635832 ([8fb05fc](https://github.com/jdfed/drip-form/commit/8fb05fc62c034fb854e7b7fd32667c9d7e78c664)), closes [#C2021012635832](https://github.com/jdfed/drip-form/issues/C2021012635832)
|
|
162
|
+
- switch,radio 单选,checkbox 问题修复 ([c19351f](https://github.com/jdfed/drip-form/commit/c19351f664386d2969bf8615befaad66ccc4eadf))
|
|
163
|
+
- text 默认值后续删除不自动添加 #C2020091124826 ([b447498](https://github.com/jdfed/drip-form/commit/b4474984fe79a812525ac4ec1e79d08b5b9c3e7e)), closes [#C2020091124826](https://github.com/jdfed/drip-form/issues/C2020091124826)
|
|
164
|
+
- treeselect 三级四级地址 NaN ([d397bf7](https://github.com/jdfed/drip-form/commit/d397bf70ae5f91d886304951eb19191542171dfb))
|
|
165
|
+
- ts 声明 ([7800503](https://github.com/jdfed/drip-form/commit/7800503addeaf8b2a75ac8fd205934d00a0c8479))
|
|
166
|
+
- ts 支持 ([f75b705](https://github.com/jdfed/drip-form/commit/f75b705eaa00890bcd9c7f442c5521e770b16849))
|
|
167
|
+
- uiSchmea 中 onChange 函数体形式未透传 fieldKey 等相关参数 #C2021011566751 ([1256615](https://github.com/jdfed/drip-form/commit/1256615ad9e560946fa86e9ac0fe0402bb481cee)), closes [#C2021011566751](https://github.com/jdfed/drip-form/issues/C2021011566751)
|
|
168
|
+
|
|
169
|
+
### Performance Improvements
|
|
170
|
+
|
|
171
|
+
- 优化右侧面板联动渲染区的逻辑 ([2233a14](https://github.com/jdfed/drip-form/commit/2233a1472d630df83da6984fcdba0f52a93ccfaa))
|
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# `@jdfed/hooks`
|
|
2
|
+
|
|
3
|
+
> babelform 通用 hooks
|
|
4
|
+
|
|
5
|
+
## useClickOne
|
|
6
|
+
|
|
7
|
+
- 控制按钮只能点击一次
|
|
8
|
+
|
|
9
|
+
#### Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
import React, { useState } form 'react
|
|
13
|
+
import { useClickOne } from '@jdfed/hooks'
|
|
14
|
+
import { Button } from 'antd'
|
|
15
|
+
|
|
16
|
+
const Demo = () => {
|
|
17
|
+
|
|
18
|
+
const _setCount = useClickOne(() => {
|
|
19
|
+
/*
|
|
20
|
+
* 做些操作
|
|
21
|
+
*/
|
|
22
|
+
}, [])
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<Button onCLick={_setCount}></Button>
|
|
27
|
+
</>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## useEventCallback
|
|
34
|
+
|
|
35
|
+
- 重写 useCallback(保证函数即使 dependencies 依赖改变。也不会重新生成) 解决因为 useCallback 的依赖频繁变化导致 useCallback 缓存效果很差甚至影响性能的问题 fn 函数 dependencies 依赖数组
|
|
36
|
+
|
|
37
|
+
#### Usage
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
import React, { useState } form 'react
|
|
41
|
+
import { useEventCallback, useField } from '@jdfed/hooks'
|
|
42
|
+
import { Button } from 'antd'
|
|
43
|
+
|
|
44
|
+
const Demo = (fieldData) => {
|
|
45
|
+
const [initValue, setValue] = useState(fieldData)
|
|
46
|
+
const _onChange = useField(
|
|
47
|
+
{ fieldKey, onChange, options: { isUploader: true } },
|
|
48
|
+
dispatch
|
|
49
|
+
)
|
|
50
|
+
change = useEventCallback(() => {
|
|
51
|
+
(value) => {
|
|
52
|
+
setValue(value)
|
|
53
|
+
}
|
|
54
|
+
}, [_onChange])
|
|
55
|
+
return (
|
|
56
|
+
<>
|
|
57
|
+
<Input onChange={change} />
|
|
58
|
+
</>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## useField
|
|
65
|
+
|
|
66
|
+
- 将表单数据保存为不可变数据
|
|
67
|
+
|
|
68
|
+
#### Usage
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
useField({ fieldKey , onChange , options })
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## useModal
|
|
75
|
+
|
|
76
|
+
- 设置 modal 的展示隐藏
|
|
77
|
+
|
|
78
|
+
#### Usage
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
import React, { useState } form 'react
|
|
82
|
+
import { useModal } from '@jdfed/hooks'
|
|
83
|
+
import { Modal } from 'antd'
|
|
84
|
+
|
|
85
|
+
const Demo = () => {
|
|
86
|
+
const [defaultStatus] = useState(false)
|
|
87
|
+
const [visible] = useModal(defaultStatus)
|
|
88
|
+
return (
|
|
89
|
+
<>
|
|
90
|
+
<Modal visible=(visible)/>
|
|
91
|
+
</>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## usePrevious
|
|
98
|
+
|
|
99
|
+
- 返回上一次的 value 值
|
|
100
|
+
|
|
101
|
+
#### Usage
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
import React, { useState } form 'react
|
|
105
|
+
import { usePrevious } from '@jdfed/hooks'
|
|
106
|
+
|
|
107
|
+
const Demo = () => {
|
|
108
|
+
const [defaultStatus] = useState(false)
|
|
109
|
+
//上一次value的值
|
|
110
|
+
const preValue = usePrevious(defaultValue)
|
|
111
|
+
return (
|
|
112
|
+
<div>{value}</div>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## useQuery
|
|
119
|
+
|
|
120
|
+
- 查询表单数据
|
|
121
|
+
|
|
122
|
+
#### Usage
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
cosnt queryOptionsFuc = useQuery({}, dispatch)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## useRefProp
|
|
129
|
+
|
|
130
|
+
- 当 callback 依赖过多时,使用 useRefProp 防止 onCLick 事件多次生成
|
|
131
|
+
|
|
132
|
+
#### Usage
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
import {useRefProp} from 'hooks/index'
|
|
136
|
+
const MyComponent = ()=> {
|
|
137
|
+
const ref = useRefProp()
|
|
138
|
+
const onClick = useRefProp(()=>{ const {a,b,c,d}=ref.current click事件 },[])
|
|
139
|
+
return <div onClick={onClick}>
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## useValidate
|
|
144
|
+
|
|
145
|
+
- 实时校验表单数据
|
|
146
|
+
|
|
147
|
+
#### Usage
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
const validate = () => {
|
|
151
|
+
......
|
|
152
|
+
......
|
|
153
|
+
return {
|
|
154
|
+
pass,
|
|
155
|
+
errors,
|
|
156
|
+
errorsMap,
|
|
157
|
+
formData: newFormData,
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const validateDebounce = useValidate(validate)
|
|
162
|
+
```
|