React - Fragment

About

A component return always a fragment (A part of the React tree)

When a component returns multiple stacked component, you need to wrap them:

  • around a div element
  • or a React.Fragment component (to avoid adding an html element)

Example

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

Documentation / Reference


Powered by ComboStrap