1. When the parent component updates a value that is the props of the child component, this function is triggered. This can be used to update props, or wrap props and then update to state
ComponentWillReceiveProps (newProps oldProps) {/ / this function (componentWillReceiveProps) invokes the enclosing setState () will not cause the second rendering. If (newProps. Property! == lodProps. Property) {this.setState({property :newProps. Properties})}}Copy the code
2. Re-render components after updating a value (to optimize performance, only render components when the Eu value is updated to avoid re-rendering sub-components)
ShouldComponentUpdate (newProps) {if (newProps. SomeData! == this.props.someData){ return true }else { return false } }Copy the code
3. Clear timers and some DOM manually created
ComponentWillUnmount () {componentWillUnmount() {componentWillUnmount() {componentWillUnmount() {data.updatetask = null;Copy the code