Skip to content

Commit 1b7f4e7

Browse files
committed
docs: modify docs subscribe
1 parent 5a60f83 commit 1b7f4e7

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

docs/intro/useSubscribe.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ toc: content
99

1010
# Subscribe to latest value
1111

12-
Using form model data **model** to control form controls through dot assignment. However, this will not cause the entire view to be re-rendered, thus achieving part of the performance optimization. If you directly use model.xx to render the latest value outside the form item, it may not achieve the expected effect.
12+
Using form model data **model** to control form controls through point assignment. However, this will not cause the entire view to be re-rendered, which means that it cannot be consumed as a state variable externally. This is also part of achieving performance optimization. If you want to directly use model.xx to render the latest value outside the form item, it may not achieve the expected effect.
1313

14-
Therefore, we can use the **useSubscribe** hook to solve this problem.
14+
Therefore, we can use **useSubscribe** hook to solve this problem.
15+
16+
**useSubscribe** uses a deep comparison algorithm, which means that as long as the new value and the old value are exactly the same, no matter how deep the hierarchy is, it will not re-render.
1517

1618
### <Mdh>Basic Usage</Mdh>
1719

docs/intro/useSubscribe.zh-CN.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ toc: content
99

1010
# 订阅最新值
1111

12-
使用表单模型数据 _model_ 通过点赋值可以对表单控件进行受控。然而,这不会引起整体视图的重新渲染,从而实现性能优化的一部分。如果你直接使用 model.xx 在表单项外部渲染最新的值,它可能无法达到预期的效果。
12+
使用表单模型数据 _model_ 通过点赋值可以对表单控件进行受控。然而这不会引起整体视图的重新渲染,也就是说在外部无法让它作为一个state状态变量去消费。这也是实现性能优化的一部分。如果你想直接使用 model.xx 在表单项外部渲染最新的值,它可能无法达到预期的效果。
1313

1414
因此,我们可以借助 _useSubscribe_ hook 来解决这个问题。
1515

16+
_useSubscribe_ 采用深度对比算法,也就是说只要新的value和旧的value不管层级多深只要值完全相同那它就不会re-render。
17+
1618
### <Mdh>基本用法</Mdh>
1719

1820
使用 _useSubscribe_ 订阅某个表单控件的值。

docs/intro/useWatch.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ toc: content
1111

1212
**React Form Simple** provides form watch functionality, which is very useful for handling specific logic when certain form fields change.
1313

14+
**useWatch** uses a deep comparison algorithm, which means that as long as the new value and the old value are exactly the same, no matter how deep the level is, it will not trigger the listener function.
15+
1416
### <Mdh>Basic Usage</Mdh>
1517

1618
Use **useWatch** to monitor changes in a specific field.

docs/intro/useWatch.zh-CN.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ toc: content
1111

1212
_React Form Simple_ 提供表单监听操作,对于在某些表单项字段变化后需要处理特定逻辑的情况非常有用。
1313

14+
_useWatch_ 采用深度对比算法,也就是说只要新的value和旧的value不管层级多深只要值完全相同那它就不会触发listener函数。
15+
1416
### <Mdh>基本用法</Mdh>
1517

1618
使用 _useWatch_ 监听某个字段的变化。

0 commit comments

Comments
 (0)