React Fragments

Just posting this for people to read.

I had no idea this was a thing and I’ve been hacking away at my components to get around the limitations exactly as described in the page. facepalm thats what you get for not being thorough when reading the docs…

A common pattern in React is for a component to return multiple elements. Fragments let you group a list of children without adding extra nodes to the DOM.

render() {
  return (
    <React.Fragment>
      <ChildA />
      <ChildB />
      <ChildC />
    </React.Fragment>
  );
}
3 Likes

Being able to use <></> makes things a lot easier

1 Like