@ -51,10 +52,11 @@ To address this limitation, React 16.0 added support for [returning an array of
```jsx
```jsx
render() {
render() {
return [
return [
"Text with",
"Text children",
<akey="link1"href="/foo">multiple</a>,
<buttonkey="button1">interleaved</button>,
<akey="link2"href="/bar">links</a>,
"with",
"inside it."
<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.
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() {
render() {
return (
return (
<Fragment>
<Fragment>
Text with
Text children
<ahref="/foo">multiple</a>
<button>interleaved</button>
<ahref="/bar">links</a>
with
inside it.
<button>other</button>
children.
</Fragment>
</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:
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: