@ -51,10 +52,11 @@ To address this limitation, React 16.0 added support for [returning an array of
```jsx
render() {
return [
"Text with",
<akey="link1"href="/foo">multiple</a>,
<akey="link2"href="/bar">links</a>,
"inside it."
"Text children",
<buttonkey="button1">interleaved</button>,
"with",
<buttonkey="button2">other</button>,
"children."
];
}
```
@ -67,14 +69,15 @@ However, this has some confusing differences from normal JSX:
To provide a more consistent authoring experience for fragments, React now provides a first-class `Fragment` component that can be used in place of arrays.
```jsx{3,8}
```jsx{3,9}
render() {
return (
<Fragment>
Text with
<ahref="/foo">multiple</a>
<ahref="/bar">links</a>
inside it.
Text children
<button>interleaved</button>
with
<button>other</button>
children.
</Fragment>
);
}
@ -105,14 +108,15 @@ const Fragment = React.Fragment;
Fragments are a common pattern in our codebases at Facebook. We anticipate they'll be widely adopted by other teams, too. To make the authoring experience as convenient as possible, we're adding syntactical support for fragments to JSX: