What do curly braces mean in JSX (React)?

前端 未结 4 1825
终归单人心
终归单人心 2020-11-29 01:26

For an example, to set a style in react you could do

var css = {color: red}

and

Hello world

4条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 01:56

    You put curly braces when you want to use the value of a variable inside "html" (so inside the render part). It's just a way of telling the app to take the value of the variable and put it there, as opposed to a word.

提交回复
热议问题