-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# class properties | ||
|
||
## defaultProps | ||
- defaultProps 可以为 Class 组件添加默认 props。 | ||
- 这一般用于 props 未赋值,但又不能为 null 的情况。 | ||
|
||
## displayName | ||
- displayName 字符串多用于调试消息。 | ||
- 通常,你不需要设置它,因为它可以根据函数组件或 class 组件的名称推断出来。 | ||
- 如果调试时需要显示不同的名称或创建高阶组件,请参阅使用 displayname 轻松进行调试了解更多。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# instance properties | ||
> 实例属性。 | ||
|
||
## props | ||
- this.props 包括被该组件调用者定义的 props。欲了解 props 的详细介绍,请参阅组件 & Props。 | ||
- 需特别注意,this.props.children 是一个特殊的 prop,通常由 JSX 表达式中的子组件组成,而非组件本身定义。 | ||
|
||
## state | ||
- 组件中的 state 包含了随时可能发生变化的数据。state 由用户自定义,它是一个普通 JavaScript 对象。 | ||
- 如果某些值未用于渲染或数据流(例如,计时器 ID),则不必将其设置为 state。此类值可以在组件实例上定义。 | ||
- 欲了解关于 state 的更多信息,请参阅 State & 生命周期。 | ||
- 永远不要直接改变 this.state,因为后续调用的 setState() 可能会替换掉你的改变。 | ||
- 请把 this.state 看作是不可变的。 |