Skip to content

docs: translate hooks-custom #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 14, 2019
Merged

docs: translate hooks-custom #72

merged 2 commits into from
Jul 14, 2019

Conversation

neighborhood999
Copy link
Member

No description provided.

@netlify
Copy link

netlify bot commented Jun 27, 2019

Deploy preview for zh-hant-reactjs-org ready!

Built with commit 1d254a8

https://deploy-preview-72--zh-hant-reactjs-org.netlify.com

@neighborhood999 neighborhood999 force-pushed the building-your-own-hooks branch from c784674 to e53550e Compare June 27, 2019 03:44
@neighborhood999 neighborhood999 force-pushed the building-your-own-hooks branch from e53550e to 5b8f9dc Compare June 28, 2019 02:46
Copy link
Member

@chloewlin chloewlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Only a few typos.


When we want to share logic between two JavaScript functions, we extract it to a third function. Both components and Hooks are functions, so this works for them too!
當我們想要共享邏輯在兩個 JavaScript function 之間時,我們提取它成為第三個 function。Componet 和 Hook 兩者都是 function,所以這也適用於它們!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
當我們想要共享邏輯在兩個 JavaScript function 之間時,我們提取它成為第三個 function。Componet 和 Hook 兩者都是 function,所以這也適用於它們!
當我們想要共享邏輯在兩個 JavaScript function 之間時,我們提取它成為第三個 function。Component 和 Hook 兩者都是 function,所以這也適用於它們!


Try to resist adding abstraction too early. Now that function components can do more, it's likely that the average function component in your codebase will become longer. This is normal -- don't feel like you *have to* immediately split it into Hooks. But we also encourage you to start spotting cases where a custom Hook could hide complex logic behind a simple interface, or help untangle a messy component.
盡量不要過早地加入抽象。現在 function component 可以做更多的事,在你 codebase 中的 function componnet 程式碼平均可能都會變得更長。這都是正常的 -- 不要覺得你*必須*馬上把它拆分成 Hook。但我們也鼓勵你開始發現自定義的 Hook 可以隱藏簡單 interface 背後的複雜邏輯情況,或者幫忙解開一個混亂的 component
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
盡量不要過早地加入抽象。現在 function component 可以做更多的事,在你 codebase 中的 function componnet 程式碼平均可能都會變得更長。這都是正常的 -- 不要覺得你*必須*馬上把它拆分成 Hook。但我們也鼓勵你開始發現自定義的 Hook 可以隱藏簡單 interface 背後的複雜邏輯情況,或者幫忙解開一個混亂的 component。
盡量不要過早地加入抽象。現在 function component 可以做更多的事,在你 codebase 中的 function component 程式碼平均可能都會變得更長。這都是正常的 -- 不要覺得你*必須*馬上把它拆分成 Hook。但我們也鼓勵你開始發現自定義的 Hook 可以隱藏簡單 interface 背後的複雜邏輯情況,或者幫忙解開一個混亂的 component。

@chloewlin chloewlin merged commit f336876 into master Jul 14, 2019
@neighborhood999 neighborhood999 deleted the building-your-own-hooks branch July 14, 2019 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants