`

React

 
阅读更多

一、React 解决数据不断变化的大型应用

 

1:不需要手动的操作DOM对象,将状态和内容对应起来,状态改变内容是如何改变。

2:提高代码复用率:组件将数据和逻辑封装

3:React Native 编写移动端跨平台的应用

 

二、React组件生命周期:提供钩子函数

React组件包含state状态、prop属性

Prop 是父组件传递子组件的,state是组件内部,一个state对应一个render的结果

 

初始化阶段函数顺序

getDefaultProps:第一次调用时

getInitialState:

componentWillMount:组件在渲染到页面之前

render:

componentDidMount:组件在渲染到页面之后

 

运行中

componentWillReceiveProps:组件在将要接受到属性时调用(还没有到接受属性)

shouldComponentUpdate:当组件接受到新属性,新状态的时候,就会触发,可以在函数中,返回false,不再diff算法,从而提高性能

componentWillUpdate:

render:

componentDidUpdate:

 

销毁

componentWillUnmount

 

 

 

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics