zoukankan      html  css  js  c++  java
  • React生命周期函数

    export default  class ClickS extends React.Component {
      constructor (props) {
        super(props)
        this.state= {
          msg: '123'
        }
        console.log(this.props)
        console.log('挂在前')
      }
      // componentWillMount // 这个生命周期函数,现在已经被废弃
      static getDerivedStateFromProps () {
        console.log('挂在前')
        return null
      }
      shouldComponentUpdate (nextProps,nextStates) {
        // 可以用来优化render
      }
      componentWillUpdate () {
        // 函数在shouldComponentUpdate之后render之前执行
      }
      componentDidUpdate () {
        // 函数在更新完毕之后执行
      }
      componentWillUnmount () {
        // 函数在组件删除之前执行
      }
      componentWillReceiveProps () {
        // 组件第一次存在于dom中,函数不会渲染
        // 如果已存在于dom中,函数才会被执行
      }
      componentDidMount () {
        console.log('挂载完毕')
      }
      render () {
        console.log('挂载')
        return <div></div>
      }
    }
    

      

  • 相关阅读:
    linux基本命令
    Linux中常用的50个命令
    Selenium2之XPath定位
    Selenium2浏览器启动及配置
    python学习内容.05
    python学习内容.04
    python学习内容.03
    python学习内容.02
    python学习内容.01
    RESTful
  • 原文地址:https://www.cnblogs.com/js-liqian/p/11829421.html
Copyright © 2011-2022 走看看