Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3e4aa24

Browse files
hijiangtaobailnl
andauthoredMar 11, 2019
Update content/docs/hooks-custom.md
Co-Authored-By: bailnl <bailnl@qq.com>
1 parent 61743de commit 3e4aa24

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎content/docs/hooks-custom.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function useFriendStatus(friendID) {
9696

9797
此处并未包含任何新的内容——逻辑是从上述组件拷贝来的。与组件中一致,请确保只在自定义 Hook 的顶层无条件地调用其他 Hooks。
9898

99-
与 React 组件不同的是,自定义 Hook 不需要具有特殊的标识。我们可以自由的决定它的参数是什么,以及它应该返回什么(如果需要的话)。换句话说,它就像一个正常的函数。但是它的名字应该始终以 `use` 开头,这样可以一眼看出其符合[Hook 的规则](/docs/hooks-rules.html)
99+
与 React 组件不同的是,自定义 Hook 不需要具有特殊的标识。我们可以自由的决定它的参数是什么,以及它应该返回什么(如果需要的话)。换句话说,它就像一个正常的函数。但是它的名字应该始终以 `use` 开头,这样可以一眼看出其符合 [Hook 的规则](/docs/hooks-rules.html)
100100

101101
此处 `useFriendStatus` 的 Hook 目的是订阅某个好友的在线状态。这就是我们需要将 `friendID` 作为参数,并返回这位好友的在线状态的原因。
102102

0 commit comments

Comments
 (0)
Please sign in to comment.