user12719912
user12719912

Reputation:

React Native | What does this mean: <> </>

What does this thing I see with react native 0.62 data? If I wiped I couldn't see an effect.

const App = () => {
  return (
    <>       <-here
    </>      <-here
  );
};

Upvotes: 2

Views: 69

Answers (2)

Josh
Josh

Reputation: 841

That's the short syntax of writing


    <React.Fragment></React.Fragment>

However, the tags don't have any children (other nested tags or components) so it won't make a difference.

Upvotes: 2

Quentin
Quentin

Reputation: 943108

This is the short syntax for a React fragment.

JSX can only return a single "thing" so:

return (
   <div>Hello</div>
   <div>World</div>
);

… would be invalid.

A fragment allows those elements to be grouped.

return (
   <>
       <div>Hello</div>
       <div>World</div>
   </>
);

Upvotes: 3

Related Questions