From 80c13912119fc927f83eb77aab76085fbcfdc0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Fri, 1 Apr 2022 15:54:11 +0800 Subject: [PATCH] docs: Add faq (#34830) --- docs/react/faq.en-US.md | 4 ++++ docs/react/faq.zh-CN.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/docs/react/faq.en-US.md b/docs/react/faq.en-US.md index 3206212a3c..8189184535 100644 --- a/docs/react/faq.en-US.md +++ b/docs/react/faq.en-US.md @@ -126,6 +126,10 @@ ConfigProvider.config({ }); ``` +### Why shouldn't I use component internal props or state with ref? + +You should only access the API by official doc with ref. Directly access internal `props` or `state` is not recommended which will make your code strong coupling with current version. Any refactor will break your code like refactor with [Hooks](https://reactjs.org/docs/hooks-intro.html) version, delete or rename internal `props` or `state`, adjust internal node constructor, etc. + ### How to spell Ant Design correctly? - ✅ **Ant Design**: Capitalized with space, for the design language. diff --git a/docs/react/faq.zh-CN.md b/docs/react/faq.zh-CN.md index 12a697f994..db620ae746 100644 --- a/docs/react/faq.zh-CN.md +++ b/docs/react/faq.zh-CN.md @@ -140,6 +140,10 @@ ConfigProvider.config({ }); ``` +### 为什么我不应该通过 ref 访问组件内部的 props 和 state? + +你通过 ref 获得引用时只应该使用文档提供的方法。直接读取组件内部的 `props` 和 `state` 不是一个好的设计,这会使你的代码与组件版本强耦合。任何重构都可能会使你的代码无法工作,其中重构包括且不仅限于改造成 [Hooks](https://reactjs.org/docs/hooks-intro.html) 版本、移除 / 更名内部 `props` 与 `state`、调整内部 React 节点结构等等。 + ### 如何正确的拼写 Ant Design? - ✅ **Ant Design**:用空格分隔的首字母大写单词,指代设计语言。