What is workflow of the React

前端 未结 2 1502
日久生厌
日久生厌 2021-01-31 03:16

The code below is from React, which updates the DOM dynamically. I used the tutorial by Facebook react but did not understand the whole code, i.e which part of the

2条回答
  •  被撕碎了的回忆
    2021-01-31 03:56

    You can find more general explanation on React official page. Generally the react lifecycle can be described by the following stages (which can repeat multiple times once the components is created):

    Initializing values (only once):

        constructor(){ ... }
    

    Mounting, if you need to add something after initial rendering (only once):

        componentDidMount(){...}
    

    Re-rendering functions, variables and components

        myArrowFunction = () => {
          ...
          this.setState({...})
          ...  
        }   
    

    Updating:

        componentDidUpdate()}{...}
        shouldComponentUpdate(){...}
    

    Unmounting:

        componentWillUnmount(){...}
    

    Rendering happens here

        render(){...}
    

提交回复
热议问题