Add reason why adding div was bad (#30906)

* Add reason why adding div was bad

* Made reason clear
This commit is contained in:
Rajasimha Reddy
2018-12-07 14:54:28 +05:30
committed by Manish Giri
parent 8a5ae5a3f4
commit 0ae42fd4ac

View File

@@ -8,7 +8,7 @@ Fragments are a way to return multiple elements from the render method without u
When attempting to render multiple sibling elements without an enclosing tag in JSX, you will see the error message of `Adjacent JSX elements must be wrapped in an enclosing tag`.
In the past, a frequent solution was to use either a wrapping div or span element. However, version 16.0 of React introduced the addition of `Fragment`, which makes this no longer necessary.
In the past, a frequent solution was to use either a wrapping div or span element, which was not elegant as it would increase the size of DOM tree and this is because of the way JSX works as multiple elements should be wrapped in a div. However, version 16.0 of React introduced the addition of `Fragment`, which makes this no longer necessary.
`Fragment` acts a wrapper without adding unnecessary divs or spans elements to the DOM. You can use it directly from the React import: