zoukankan      html  css  js  c++  java
  • react手记(componentWillMount,componentDidMount等)

    生命周期
    componentWillMount 组件出现前 就是dom还没有渲染到html文档里面
    componentDidMount 组件渲染完成 已经出现在dom文档里
    可以再各个周期实现特定的操作

    生命周期的方法有:

    componentWillMount 在渲染前调用,在客户端也在服务端。

    componentDidMount : 在第一次渲染后调用,只在客户端。之后组件已经生成了对应的DOM结构,可以通过this.getDOMNode()来进行访问。 如果你想和其他JavaScript框架一起使用,可以在这个方法中调用setTimeout, setInterval或者发送AJAX请求等操作(防止异部操作阻塞UI)。

    componentWillReceiveProps 在组件接收到一个新的 prop (更新后)时被调用。这个方法在初始化render时不会被调用。

    shouldComponentUpdate 返回一个布尔值。在组件接收到新的props或者state时被调用。在初始化时或者使用forceUpdate时不被调用。 可以在你确认不需要更新组件时使用。

    componentWillUpdate在组件接收到新的props或者state但还没有render时被调用。在初始化时不会被调用。

    componentDidUpdate 在组件完成更新后立即调用。在初始化时不会被调用。

    componentWillUnmount在组件从 DOM 中移除的时候立刻被调用。

    React 组件生命周期:http://www.runoob.com/react/react-component-life-cycle.html

    React.Component:https://reactjs.org/docs/react-component.html#lifecycle-methods

    构成与继承:https://reactjs.org/docs/composition-vs-inheritance.html

    React组件生命周期过程说明:http://react-china.org/t/react/1740

  • 相关阅读:
    C#调用JS
    C#对象序列化(2)
    C#委托和事件(2)
    C#委托和事件(1)
    Windows Mobile Ping 命令实现
    操作 SQL Server Mobile 2005 数据库的常用 C# 代码
    Pocket PC 2003数据库操作
    C#委托和事件(3)
    C#中RSA加密解密和签名与验证的实现
    使用SqlBulkCopy数据导入和复制
  • 原文地址:https://www.cnblogs.com/cxscode/p/8399018.html
Copyright © 2011-2022 走看看