react 16.4之前 生命周期

    mounting (加载阶段)
        constructor()    加载的时候调用一次,可以初始化
		getDefaultProps()   设置默认的props,也可以用dufaultProps设置组件的默认属性。
		getInitialState()   初始化state,可以直接在
		componentWillMount()    组件加载时只调用,以后组件更新不调用,整个生命周期只调用一次,此时可以修改
		render()    react最重要的步骤,创建虚拟dom,进行diff算法,更新dom树都在此进行
		componentDidMount()    组件渲染之后调用,只调用一次

    updating(更新阶段)
        componentWillReceiveProps(nextProps)   组件加载时不调用,组件接受新的props时调用
		shouldComponentUpdate(nextProps, nextState)  组件接收到新的props或者state时调用return true就会更新dom(使用diff算法更新)rtrurn false 能阻止更新(不调用render)
		componentWillUpdata(nextProps, nextState)  组件加载时不调用,只有在组件将要更新时才调用,此时可以修改
		render()   react最重要的步骤,创建虚拟dom,进行diff算法,更新dom树都在此进行
		componentDidUpdate()   组件加载时不调用,组件更新完成后调用

    unmountimg(卸载阶段)
    	componentWillUnmount()   组件渲染之后调用,只调用一次
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值