What do these three dots in React do?

前端 未结 29 3449
不思量自难忘°
不思量自难忘° 2020-11-21 23:53

What does the ... do in this React (using JSX) code and what is it called?



        
29条回答
  •  天命终不由人
    2020-11-22 00:14

    The ...(spread operator) is used in react to:

    provide a neat way to pass props from parent to child components. e.g given these props in a parent component,

    this.props = {
      username: "danM",
      email: "dan@mail.com"
    }
    

    they could be passed in the following manner to the child,

    
    

    which is similar to this

    
    

    but way cleaner.

提交回复
热议问题