Skip to content

Commit baeebe3

Browse files
authored
Update React Native 基础知识总结.md
1 parent d6b277e commit baeebe3

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

React Native 项目实践总结/React Native 基础知识总结.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,23 @@ class Demo extends React.Component {
8383
-Unmounting:卸载
8484
componentWillUnmount()
8585

86-
```
87-
componentWillMount(),组件开始装载之前调用,在一次生命周期中只会执行一次。
88-
89-
componentDidMount(),组件完成装载之后立即调用,在一次生命周期中只会执行一次。在这里开始就可以对组件进行各种操作了,比如在组件装载完成后要显示的时候执行动画。
90-
91-
86+
```javascript
87+
componentWillMount(),组件开始装载之前调用,在一次生命周期中只会执行一次。
88+
componentDidMount(),组件完成装载之后立即调用,在一次生命周期中只会执行一次。在这里开始就可以对组件进行各种操作了,比如在组件装载完成后要显示的时候执行动画。
9289
componentWillUpdate(object nextProps, object nextState),当新的props或者state被接受时,组件属性更新之前调用,这个方法不会被初始渲染调用。不能在这个方法里使用 this.setState()。如果你要响应一个prop变化来更新state,使用componentWillReceiveProps 来替代。
9390

94-
componentDidUpdate(object prevProps, object prevState),组件属性更新之后调用,每次属性更新都会调用,这个方法不会被初始渲染调用。
95-
91+
componentDidUpdate(object prevProps, object prevState),组件属性更新之后调用,每次属性更新都会调用,这个方法不会被初始渲染调用。
9692
componentWillUnmount(),组件卸载之前调用,在这个方法里执行一些必要的清理操作,比如timers。
9793
```
9894

99-
##### 组件属性更改时会调用以下方法,在一次生命周期中可以执行多次:
95+
##### 组件属性更改时会调用以下方法,在一次生命周期中可以执行多次:
10096

97+
```javascript
10198
componentWillReceiveProps(object nextProps),已加载组件收到新的props时被调用.这个方法不会为最初的渲染调用。
10299

103100
shouldComponentUpdate(object nextProps, object nextState),组件判断是否重新渲染时调用,当新的props或者state被收到,在渲染前被调用.这个方法不会在最初的渲染被调用。
104-
101+
```
102+
105103
并没有类似的 ```componentWillReceiveState ()```的方法。一个即将到来的 prop 转变可能会导致一个 state 变化,但是反之不是。如果你需要实现一个对 state 变化相应的操作,使用 ```componentWillUpdate()```
106104

107105

0 commit comments

Comments
 (0)