對React生命週期的理解

React 16.3之前 1、getDefaultProps() 設置默認的props,也可以用dufaultProps設置組件的默認屬性. 2、getInitialState() 在使用es6的class語法時是沒有這個鉤子函數的,可以直接在constructor中定義this.state。此時可以訪問this.props 3、componentWillMount() 組件初始化時只調用,以後組
相關文章
相關標籤/搜索