Skip to content

Commit 3cf4a56

Browse files
authored
docs: migration v4 (#338)
Co-authored-by: liuyi <[email protected]>
1 parent b5fb482 commit 3cf4a56

File tree

2 files changed

+193
-1
lines changed

2 files changed

+193
-1
lines changed

docs/guide/migration-v4.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
---
2+
title: 从 v3 到 v4
3+
group: 研发
4+
order: 6
5+
---
6+
7+
本文档将帮助你把 dt-react-component 从 `3.x` 版本升级到 `4.x` 版本。
8+
9+
## 一、升级准备
10+
11+
1、请先升级到 3.x 的最新版本,保证产品本地没有报错。
12+
2、产品建议使用 `[email protected]``[email protected]`
13+
14+
- 如果你仍在使用 React 15,请参考 [React 16 升级文档](https://reactjs.org/blog/2017/09/26/react-v16.0.html#breaking-changes)
15+
- 其余 React 16 废弃生命周期 API 请参考 [迁移导引](https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path)
16+
17+
## 二、4.x 不兼容的变化
18+
19+
### 2.1、移除的组件
20+
21+
- 移除 `Breadcrumb`,迁移至 `dt-common/src/components/breadcrumb`
22+
- 移除 `GoBack`,迁移至 `dt-common/src/components/goBack`
23+
- 移除 `ChromeDownload`,迁移至 `dt-common/src/components/chromeDownload`
24+
- 移除 `LoadError`,整合进 `ErrorBoundary` 中。
25+
- 移除 `EasySelect`
26+
- 移除 `EditCell`
27+
- 移除 `EditInput`
28+
- 移除 `InterruptController`
29+
- 移除 `ScrollText`
30+
- 移除 `SearchModal`
31+
- 移除 `TableCell`
32+
- 移除 `TextMark`
33+
- 移除 `ToolModal`
34+
35+
### 2.2、组件重构更名
36+
37+
#### MulSelectDropdown [#296](https://github.com/DTStack/dt-react-component/pull/296)
38+
39+
- 重命名为 `Dropdown.Select`,产品中所有用到 `antd4 Dropdown` 的地方也可以从 RC 里面导出。
40+
- 移除 `okText``cancelText` 属性,目前从组件设计角度来看不需要这两个字段。
41+
- 移除 `renderNode`,功能迁移至 `children`
42+
- 重命名 `popupContainer``getPopupContainer`
43+
- 重命名 `onOk``onSubmit`
44+
- 优化 UI 界面。
45+
46+
```diff
47+
- import { MulSelectDropdown } from 'dt-react-component';
48+
+ import { Dropdown } from 'dt-react-component;
49+
const { Select } = Dropdown;
50+
51+
export function () => {
52+
return (
53+
- <MulSelectDropdown />
54+
+ <Select />
55+
)
56+
}
57+
```
58+
59+
#### ModalWithForm [#305](https://github.com/DTStack/dt-react-component/pull/305)
60+
61+
- 重命名为 `Modal.Form`,产品中所有用到 `antd4 Modal` 的地方也可以从 RC 里面导出。
62+
- 支持 `Modal` 导出,集成 `antd4 Modal` 所有组件和 hooks,新增 Form 组件。
63+
- 移除 `hideModalHandler`,使用 `onCancel`
64+
-`afterClose` 中重置 form 表单。
65+
- `modelClass` 重命名 `modalClassName`
66+
- 废弃 `record` 参数。
67+
68+
#### Cookies [#294](https://github.com/DTStack/dt-react-component/pull/294)
69+
70+
- 使用方式变更,由组件形式改为自定义 hooks 形式,名字变更为 `useCookieListener`
71+
- 新增 `timeout` 参数,自定义轮训时间, 默认为 `200毫秒`
72+
- 新增 `immediately` 参数,用于判断新增 `Cookie` 是否也会触发 `handler`,默认为 `false`。这里与 `3.x` 保持一致,即新增时不会触发`handler`
73+
- 细节改动:`prevCookies` 默认值为 `document.cookie``3.x` 为空字符串,导致第一次组件挂载时就会触发相关的 `handler`
74+
75+
```js
76+
useCookieListener(
77+
handler: (params: {prevCookies: string, nextCookies: string, changedFields?: Fields[]}) => void,
78+
watchFields: string[],
79+
options?: ICookieOptions
80+
)
81+
```
82+
83+
#### CopyIcon [#329](https://github.com/DTStack/dt-react-component/pull/329)
84+
85+
- 重命名为 `Copy`,基于 `useClippy` 进行二次封装。
86+
- `customRender` 属性重命名为 `button`
87+
- 新增 `hideTooltip` 属性用于控制是否隐藏 `Tooltip`
88+
- 新增 `onCopy` 回调函数。
89+
90+
#### MultiSearchInput [#316](https://github.com/DTStack/dt-react-component/pull/316)
91+
92+
- 重命名为 `Input.Match`
93+
94+
### 2.3、属性调整
95+
96+
#### MarkdownRender [#307](https://github.com/DTStack/dt-react-component/pull/307)
97+
98+
- 重命名 `text``value`
99+
- 增加 `dark` 属性,暗黑模式。
100+
- 修复 sql 语法高亮的问题。
101+
102+
#### BlockHeader [#298](https://github.com/DTStack/dt-react-component/pull/298)
103+
104+
- 移除 `isSmall`,增加 `size` 属性,共有两个尺寸 `small``middle`,默认为 `middle`
105+
106+
#### Fullscreen [#304](https://github.com/DTStack/dt-react-component/pull/304)
107+
108+
- 移除 `customIcon` 属性,禁止组件传输非定义的其他的 `props`
109+
110+
#### ProgressLine [#321](https://github.com/DTStack/dt-react-component/pull/321)
111+
112+
- 移除 `num` 属性,值通过 `title` 属性一起传入组件即可。
113+
- 移除 `needTitle` 属性,根据 `title` 属性值直接判断是否展示。
114+
- `percent` 属性改为字符串,传值需要带上 `%`
115+
- 新增 `tooltipProps` 属性,类型为 `antd4 Tooltip``TooltipProps`
116+
117+
#### GlobalLoading [#322](https://github.com/DTStack/dt-react-component/pull/322)
118+
119+
- 移除 `prefix` 属性。
120+
121+
## 三、4.x 中兼容的变化
122+
123+
### 3.1、属性调整
124+
125+
#### Empty [#295](https://github.com/DTStack/dt-react-component/pull/295)
126+
127+
- 显式暴露出 `imageStyle` 属性。
128+
- 内置图片采用 `png` 格式,且对图片文件大小进行压缩。
129+
130+
#### EllipsisText [#277](https://github.com/DTStack/dt-react-component/pull/277)
131+
132+
- 自动识别内容超过。
133+
- 在超出情况下,继承父级的鼠标浮动样式,否则为 `pointer`
134+
- `maxWitdh` 支持数字、px、% 和 calc(100% - 200px)。
135+
- 支持内容为行内元素,包括返回为行内元素的 react 组件。
136+
137+
#### StatusTag [#310](https://github.com/DTStack/dt-react-component/pull/310)
138+
139+
- 剔除冗余代码不影响之前使用。
140+
141+
#### ErrorBoundary [#308](https://github.com/DTStack/dt-react-component/pull/308)
142+
143+
- 新增参数 `errorPage`, 用于自定义错误展示页面。
144+
- 新增参数 `onError`, 当捕获错误时触发。
145+
- 内部整合了 `3.x``LoadError` 组件。
146+
147+
#### Resize [#324](https://github.com/DTStack/dt-react-component/pull/324)
148+
149+
- 新增 `observerEle` 属性,支持自定义监听元素。
150+
151+
#### SpreadSheet [#325](https://github.com/DTStack/dt-react-component/pull/325)
152+
153+
- 新增 `className` 属性,可自定义外层组件的 class 名。
154+
155+
#### KeyEventListener [#326](https://github.com/DTStack/dt-react-component/pull/326)
156+
157+
- React hook 重构
158+
159+
#### SlidePane [#330](https://github.com/DTStack/dt-react-component/pull/330)
160+
161+
- 使用 rc-drawer 重写组件,改写为函数组件。
162+
- props 变动:不可任意传入 props,保留原有支持的 props。
163+
- 新增 `bodyStyle` 可以复写面板内部的样式,一般多为 `padding` 之类的设定。
164+
165+
#### SwitchWindow [#327](https://github.com/DTStack/dt-react-component/pull/327)
166+
167+
- 改写成 hooks
168+
- 不支持 `props` 传入 `children` 的形式
169+
- 使用方式变更
170+
171+
```js
172+
useWindowSwitchListener(() => {
173+
handleSwitch();
174+
});
175+
```
176+
177+
### 3.2、新增组件
178+
179+
#### Form.Table [#293](https://github.com/DTStack/dt-react-component/pull/293)
180+
181+
- 支持 `Form` 导出,集成 `antd4 Form` 所有组件和 hooks,新增 Table 组件
182+
183+
#### CollapsibleActionItems [#300](https://github.com/DTStack/dt-react-component/pull/300)
184+
185+
- 对过多的操作项进行自动折叠,多用于表格操作列中。
186+
- 支持通过 `maxCount` 指定最大展示数量,默认为 3 个。
187+
- 支持通过 `divider``collapseIcon` 自定义分割符与折叠图标。
188+
- 支持通过 `dropdownProps``buttonProps` 进行参数透传。
189+
190+
## 五、遇到问题
191+
192+
`4.x` 做了比较多的改进和重构,我们尽可能收集了已知的所有不兼容变化和相关影响,但是有可能还是有一些场景我们没有考虑到。如果你在升级过程中遇到了问题,请到 [dt-react-component Issues](https://github.com/DTStack/dt-react-component/issues) 进行反馈,我们会尽快响应和相应改进。

docs/guide/updateLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 更新日志
33
group: 研发
4-
order: 6
4+
order: 7
55
---
66

77
<embed src="../../CHANGELOG"></embed>

0 commit comments

Comments
 (0)