What do curly braces mean in JSX (React)?

前端 未结 4 1835
终归单人心
终归单人心 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 02:03

    The outer curly braces tell the JSX parser that the syntax should be interpreted as javascript. The inner braces are used because the style variable accepts an object.

    let's break this down:

    hello

提交回复
热议问题