Skip to content

Inabillity to return many children or elements without a single parent/div #8765

Open

Description

@AbdikarimMahamud

Am shocked that no one has addressed this yet,i've only recently strarted learning react and i must say this is really limiting ..

Activity

  1. pwnjoshi commented on Nov 27, 2026

    @pwnjoshi

    You can return sibling elements without adding a wrapper to the DOM. Use a Fragment:

    function Greeting() {
      return (
        <>
          <h1>Hello</h1>
          <p>Welcome to React.</p>
        </>
      );
    }

    React receives a single JSX expression, and the browser gets the heading and paragraph as siblings. There is no extra div to affect layout. The docs show this under Return a single root element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions