passings array as props in reactjs

前端 未结 2 1824
梦谈多话
梦谈多话 2021-02-06 21:02

I am new to react.

I have been experimenting on react and I got stuck on how to pass array using props.

case-1:

var c = [\'program\'];
var Naviga         


        
2条回答
  •  时光说笑
    2021-02-06 21:26

    The curly braces only need to be used within JSX elements. Like this:

    
    

    In the case above, the {} is the way of saying: "Evaluate the expression that I passed within and pass it as a prop". Within the {} you can pass any valid JavaScript object or expression. Note that if you pass a string, and specifically for strings, you don't need the curly braces... like .

    The above code is the equivalent of this:

    var myArray = ['something'];
    
    

提交回复
热议问题