Best practice when adding whitespace in JSX

前端 未结 9 811
粉色の甜心
粉色の甜心 2020-12-02 11:35

I understand how (and why) to add a whitespace in JSX, but I am wondering what\'s best practice or if any makes any real difference?

Wrap both elements in a

9条回答
  •  心在旅途
    2020-12-02 12:34

    You can use curly braces like expression with both double quotes and single quotes for space i.e.,

    {" "} or {' '}
    

    You can also use ES6 template literals i.e.,

    `   
  • ` or ` ${value}`

    You can also use   like below (inside span)

    sample text   
    

    You can also use   in dangerouslySetInnerHTML when printing html content

提交回复
热议问题