🚫 Do Not Overuse <div> in React When working with HTML, we often use <div> to wrap multiple elements. But in React, unnecessary <div> elements can create extra nodes in the DOM. 💡 React introduced Fragments (React 16.2) to solve this problem. Why use React Fragments? • No extra DOM nodes • Cleaner and less cluttered DOM • Slightly better performance • Easy way to group multiple elements React also provides a Fragment shorthand (<> </>) which makes code cleaner and easier to write. 📌 I’ve explained this concept in a simple swipe PDF for beginners. #React #ReactJS #JavaScript #FrontendDevelopment #WebDevelopment #MohitDecodes
But the question is why would someone wrap with a div without giving the div styles/classes thats a html anti-pattern
You cannot style fragments using css. 😃
Thanks for sharing
Thanks for sharing
Thanks for sharing
Great share
Thanks for sharing
Great share
Great share
Good Information. Just add 1 more answer in this. When Do We Use Full Syntax? If we need to pass a key: <React.Fragment key={item.id}> <h1>{item.name}</h1> </React.Fragment> Short syntax <> </> does NOT support keys.