Why are Fragments in React 16 better than container divs?

后端 未结 6 1713
陌清茗
陌清茗 2020-12-22 15:39

In React 16.2, improved support for Fragments has been added. More information can be found on React\'s blog post here.

We are all familiar with the fol

6条回答
  •  感动是毒
    2020-12-22 16:14

    1. Using ..., we can add a parent tag to our JSX elements without adding an extra node to the DOM.
    2. you can replace the extra div tags with React.Fragment
    3. writing React.Fragment every time is too long for you. React.Fragment has a shorthand syntax that you can use. It is <>....

提交回复
热议问题