The execution order of the life cycle of components in different states React

  1. First getDefaultPropsmount: getInitialState, componentWillMount, render, ,componentDidMount
  2. Uninstall:componentWillUnmount
  3. getInitialStateRemount: componentWillMount, render, ,componentDidMount
  4. Component componentWillReceivePropsUpdate: shouldCompnentUpdate, componentWillUpdate, ,componentDidUpdate

Why remount when there is no getDefaultProps, because React, the life cycle management through three stages: MOUNTING, RECEIVE_PROPS and UNMOUNTING, 3 phases correspond to three methods: mountComponent, updateComponent and ummountComponent; mountComponent which is responsible for managing the life cycle getInitialState, , componentWillMount, render, componentDidMountas getDefaultPropsis managed by the constructor, but also the entire life cycle of the first to begin, and mountComponent unable to call getDefaultProps, so why getDefaultPropsone of the reasons execute only.

: Original Big Box  perform different React order life cycle component status


Guess you like

Origin www.cnblogs.com/petewell/p/11607326.html