Home > shorts > Using fragments in React

Using fragments in React


Fragments look like empty JSX tags <></> They let you group a list of children without adding extra nodes to the DOM. If you don't need div for styling purposes use fragment instead.

const children = (
    <>
        <h1>Todo list</h1>
        <ul>
            <li>Learn React</li>
            <li>Learn JSX</li>
        </ul>
    </>
)
© 2021, Andrew Losseff